For some reason, ldap and directory services does not work when the computer is not joined to the domain. The error messages from .net is domain not available. Anyone know what needs to be done?
出于某种原因,当计算机未加入域时,ldap和目录服务不起作用。来自.net的错误消息不可用。有人知道需要做什么吗?
the basic...
domainAndUsername = domain + @"\" + username;
entry = new DirectoryEntry(_path, domainAndUsername, pwd);
entry.AuthenticationType = FindAuthTypeMicrosoft(authType);
... doesn't seem to work when logged in locally to the machine when trying to supply testdomain.com to the code above.
...当尝试将testdomain.com提供给上面的代码时,在本地登录到计算机时似乎不起作用。
Even though I can ping testdomain.com without an issue. What is different or the problem?
即使我可以毫无问题地ping testdomain.com。有什么不同或问题?
3 个解决方案
#1
This code has worked for me in the past (though I admit I am not in a position to test it right now):
这段代码过去对我有用(虽然我承认我现在无法测试它):
DirectoryEntry entry = new DirectoryEntry("LDAP://server-name/DC=domainContext,DC=com");
entry.Username = @"DOMAIN\account";
entry.Password = "...";
DirectorySearcher searcher = new DirectorySearcher(entry);
searcher.Filter = "(&(objectClass=user)(sn=Jones))";
SearchResultCollection results = searcher.FindAll();
The hardest part (for me anyway) is figuring out the "connection string" details. I generally rely on ADSI Edit and AD Explorer to help me figure out what the correct values are. Softerra LDAP Browser - the free version is a bit older, v2.6 and tucked away in their download section.
最困难的部分(无论如何)正在弄清楚“连接字符串”的细节。我通常依靠ADSI Edit和AD Explorer来帮助我弄清楚正确的值是什么。 Softerra LDAP浏览器 - 免费版本有点旧,v2.6,隐藏在下载部分。
#2
Directory services rely on an ActiveDirectory. So you need to add the machine to an Domain or explicitly supply the domain controller. Note that domain does not mean a domain name from the domain name system. It means a ActiveDirectory Domain.
目录服务依赖于ActiveDirectory。因此,您需要将计算机添加到域或显式提供域控制器。请注意,域不代表域名系统中的域名。它表示ActiveDirectory域。
#3
i was leaving _path blank. sorry my own issue.
我正在离开_path空白。抱歉我自己的问题。
#1
This code has worked for me in the past (though I admit I am not in a position to test it right now):
这段代码过去对我有用(虽然我承认我现在无法测试它):
DirectoryEntry entry = new DirectoryEntry("LDAP://server-name/DC=domainContext,DC=com");
entry.Username = @"DOMAIN\account";
entry.Password = "...";
DirectorySearcher searcher = new DirectorySearcher(entry);
searcher.Filter = "(&(objectClass=user)(sn=Jones))";
SearchResultCollection results = searcher.FindAll();
The hardest part (for me anyway) is figuring out the "connection string" details. I generally rely on ADSI Edit and AD Explorer to help me figure out what the correct values are. Softerra LDAP Browser - the free version is a bit older, v2.6 and tucked away in their download section.
最困难的部分(无论如何)正在弄清楚“连接字符串”的细节。我通常依靠ADSI Edit和AD Explorer来帮助我弄清楚正确的值是什么。 Softerra LDAP浏览器 - 免费版本有点旧,v2.6,隐藏在下载部分。
#2
Directory services rely on an ActiveDirectory. So you need to add the machine to an Domain or explicitly supply the domain controller. Note that domain does not mean a domain name from the domain name system. It means a ActiveDirectory Domain.
目录服务依赖于ActiveDirectory。因此,您需要将计算机添加到域或显式提供域控制器。请注意,域不代表域名系统中的域名。它表示ActiveDirectory域。
#3
i was leaving _path blank. sorry my own issue.
我正在离开_path空白。抱歉我自己的问题。