java - JNDI .Net 实现

标签 java c# oracle c#-4.0 jndi

我有一个 java 代码,它使用 JNDI 访问目录并获取用户/密码以登录 samba。 我需要的是一种将其转换为 .Net 代码的方法。不过我读了这个MSDN article并无法理解。我尝试以多种不同的方式使用 DirectorySearcher 类。

有一小段java代码:

try {
    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
    env.put(Context.PROVIDER_URL, jndiServerURL);

    ic = new InitialContext(env);

    fileSystemProxy = (T3FileSystemProxy) ic.lookup("Credential");
    } 
catch (Exception e) {
    e.printStackTrace();
}

有人知道如何实现吗?

最佳答案

不幸的是我无法实现 JNDI,因为它是 Java 的接口(interface)。我必须获取 UNC 路径并使用网络凭据进行身份验证。

using (new UNCPathAccess(Path.GetDirectoryName(pathPdf), username, string.Empty, password))
{
    Email.Send(subject, body, email, attachments);
}

关于java - JNDI .Net 实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24873595/

相关文章:

java.lang.ClassCastException : oracle. jdbc.driver.T4CConnection 无法转换为 com.arjuna.ats.internal.arjuna.recovery.Connection

java - 从 html 表单调用 servlet,无需 web.xml 部署描述符

java - 无法访问带注释的 Spring 服务

java - 如何更新文本文件中的某些行?

c# - 静态方法应该修改对象还是返回一个新对象

c# - 从 Web App 调用时,System.Reflection.Assembly.GetEntryAssembly() 为空

java.lang.NoSuchFieldError : INSTANCE with Spring Social on Azure 错误

c# - 在脚本中发布构建事件#

oracle blob 文本搜索

sql - ORA-01821 : date format not recognized error for ISO 8601 date with local time