首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >针对Active Directory的表单身份验证- LDAP协议

针对Active Directory的表单身份验证- LDAP协议
EN

Stack Overflow用户
提问于 2011-01-28 01:19:11
回答 3查看 4.1K关注 0票数 0

我需要创建一个网页,根据现有的活动目录对用户进行身份验证。该域实际上是一个云计算配置,其中堆栈上有一个域控制器和多个其他服务器。

我知道可以使用System.DirectoryServices名称空间中的对象。但是,我似乎无法通过LDAP://domain.com地址将代码路径到active directory。似乎没有进行任何交流。我怀疑有一些初始配置是必要的,或者是安全措施阻止了通信。

我正在使用MSDN:http://msdn.microsoft.com/en-us/library/ms180890(v=vs.80).aspx中的这个例子。

我得到一个错误,说服务器不能运行。

EN

回答 3

Stack Overflow用户

发布于 2011-01-28 01:36:16

看看这个链接(用web.archive.org替换旧的):

http://www.codeproject.com/KB/system/everythingInAD.aspx#35

下面是获取默认条目的方法:

代码语言:javascript
复制
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,请执行以下操作:

代码语言:javascript
复制
DirectoryEntry("LDAP://yourcompany.local/RootDSE");
DirectoryEntry("LDAP://example.com/RootDSE");

或者让.NET协商协议:

代码语言:javascript
复制
DirectoryEntry("yourcompany.local/RootDSE");
DirectoryEntry("example.com/RootDSE");
票数 2
EN

Stack Overflow用户

发布于 2011-01-28 01:33:04

代码语言:javascript
复制
LDAP://domain

当服务器加入到所述域中时可以使用;然后,在给定正确的DNS配置的情况下,它应该能够解析域控制器。

否则,如果您有域控制器的fqdn或ip地址,则可以使用

代码语言:javascript
复制
LDAP://fqdn.of.domaincontroller /* or */ LDAP://100.10.100.10

这样做意味着您被绑定到该DC,因此如果该计算机停机或被移除,您将无法进行身份验证。

票数 0
EN

Stack Overflow用户

发布于 2018-10-31 03:26:16

已经有一段时间了,但我想我完全明白这个问题是关于什么的。

我在这个宏伟的free to test LDAP server上进行了测试

代码语言:javascript
复制
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。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4819612

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档