我需要创建一个网页,根据现有的活动目录对用户进行身份验证。该域实际上是一个云计算配置,其中堆栈上有一个域控制器和多个其他服务器。
我知道可以使用System.DirectoryServices名称空间中的对象。但是,我似乎无法通过LDAP://domain.com地址将代码路径到active directory。似乎没有进行任何交流。我怀疑有一些初始配置是必要的,或者是安全措施阻止了通信。
我正在使用MSDN:http://msdn.microsoft.com/en-us/library/ms180890(v=vs.80).aspx中的这个例子。
我得到一个错误,说服务器不能运行。
发布于 2011-01-28 01:36:16
看看这个链接(用web.archive.org替换旧的):
http://www.codeproject.com/KB/system/everythingInAD.aspx#35
下面是获取默认条目的方法:
try
{
System.DirectoryServices.DirectoryEntry AdRootDSE = new System.DirectoryServices.DirectoryEntry("LDAP://rootDSE");
string rootdse = System.Convert.ToString(AdRootDSE.Properties["defaultNamingContext"].Value);
if (!rootdse.StartsWith("LDAP://", StringComparison.OrdinalIgnoreCase) && !rootdse.StartsWith("LDAPS://", StringComparison.OrdinalIgnoreCase))
{
rootdse = "LDAP://" + rootdse;
}
return rootdse;
}
catch (Exception ex)
{
}要获取非默认域的rootDSE,请执行以下操作:
DirectoryEntry("LDAP://yourcompany.local/RootDSE");
DirectoryEntry("LDAP://example.com/RootDSE");或者让.NET协商协议:
DirectoryEntry("yourcompany.local/RootDSE");
DirectoryEntry("example.com/RootDSE");发布于 2011-01-28 01:33:04
LDAP://domain当服务器加入到所述域中时可以使用;然后,在给定正确的DNS配置的情况下,它应该能够解析域控制器。
否则,如果您有域控制器的fqdn或ip地址,则可以使用
LDAP://fqdn.of.domaincontroller /* or */ LDAP://100.10.100.10这样做意味着您被绑定到该DC,因此如果该计算机停机或被移除,您将无法进行身份验证。
发布于 2018-10-31 03:26:16
已经有一段时间了,但我想我完全明白这个问题是关于什么的。
我在这个宏伟的free to test LDAP server上进行了测试
var path = "LDAP://ldap.forumsys.com:389/dc=example,dc=com";
var user = $@"uid={username},dc=example,dc=com";
var pass = "password";
var directoryEntry = new DirectoryEntry(path, user, pass, AuthenticationTypes.None);
var searcher = new DirectorySearcher(directoryEntry);
searcher.PropertiesToLoad.Add("*");
var searchResult = searcher.FindOne();然而,我并不完全理解所有这些行的作用,并寻找解决方案,我找到了一些建议。
在path上,"LDAP://“字符串应该在块mayus上。
在user中,有时您需要使用"cn=username-admin“来验证管理员,请确保还将Authentication type设置为ServerBind。
https://stackoverflow.com/questions/4819612
复制相似问题