【发布时间】:2012-07-25 05:10:21
【问题描述】:
在我们公司,我们有一个项目应该将 Novell eDirectory 与 .net 应用程序一起使用。 我已尝试使用 Novell Api (http://www.novell.com/coolsolutions/feature/11204.html) 在 .NET 应用程序之间进行连接。它工作正常。
但是,根据要求,我们特别需要 .net API 以不与 Novell Api 连接,这无法正常工作。与 .NET Api DirectoryServices 的连接和绑定不起作用。
我们的 Novell eDirectory 使用以下凭据安装:
IP地址:10.0.x.xx(witsxxx.companyname.com)
树:SXXXX
新树上下文:WIxxxK01-NDS.OU=STATE.O=ORG
ADMIN 上下文为:ou=STATE,o=ORG
管理员:管理员
密码:管理员
我使用了 Novell Api 并使用了以下代码
String ldapHost ="10.0.x.xx";
String loginDN = "cn=admin,cn=WIxxxK01-NDS,OU=STATE,o=ORG";
String password = string.Empty;
String searchBase = "o=ORG";
String searchFilter = "(objectclass=*)";
Novell.Directory.Ldap.LdapConnection lc = new Novell.Directory.Ldap.LdapConnection();
try
{
// connect to the server
lc.Connect(ldapHost, LdapPort);
// bind to the server
lc.Bind(LdapVersion, loginDN, password);
}
这样绑定正确,可以搜索了。
现在我的问题是当我尝试使用 .NET APi 和使用 System.DirectoryServices
或System.DirectoryServices.Protocols,它没有连接或绑定。
我什至无法测试以下DirectoryEntry.Exists 方法。它会例外。
string myADSPath = "LDAP://10.0.x.xx:636/OU=STATE,O=ORG";
// Determine whether the given path is correct for the DirectoryEntry.
if (DirectoryEntry.Exists(myADSPath))
{
Console.WriteLine("The path {0} is valid",myADSPath);
}
else
{
Console.WriteLine("The path {0} is invalid",myADSPath);
}
上面写着Server is not operational 或Local error occurred 等。我不知道目录路径发生了什么。
我试过了
DirectoryEntry de = new DirectoryEntry("LDAP://10.0.x.xx:636/O=ORG,DC=witsxxx,DC=companyname,DC=com", "cn=admin,cn=WIxxxK01-NDS,o=ORG", "admin");
DirectorySearcher ds = new DirectorySearcher(de, "&(objectClass=user)");
var test = ds.FindAll();
一切都会例外。
你能帮我解决这个问题吗? DirectoryEntry 的userDN 应该如何?
我也将System.DirectoryServices.Protocols.LdapConnection 与LdapDirectoryIdentifier 和System.Net.NetworkCredential 一起使用,但没有结果。只有相同的例外。
感谢您宝贵的时间和帮助。
谢谢, 比努
【问题讨论】:
-
据我记忆,我从来没有让它正常工作。 MSDN documentation on DirectoryEntry 还明确指出:DirectoryEntry 类封装了 Active Directory 域服务 层次结构中的节点或对象。 -
System.DirectoryServices真正面向 Active目录 - 它并不真正支持其他任何东西。所以要么继续使用本机 Novell API,要么你需要研究低级的原始 LDAP (S.DS.Protocols) -
我也尝试了使用原始 LDAP (S.DS.Protocols) 的以下代码,但出现异常。尝试 { LdapDirectoryIdentifier lid = new LdapDirectoryIdentifier("10.0.x.xx",389); System.Net.NetworkCredential cred = new System.Net.NetworkCredential("cn=admin,cn=witsxxx-NDS,o=ORG", string.Empty);使用 (System.DirectoryServices.Protocols.LdapConnection lconn = new System.DirectoryServices.Protocols.LdapConnection(lid)) { lconn.Bind(cred); } }