gpt4 book ai didi

c# - 如何在未使用 c# 加入 Microsoft Active Directory 中的域时对 ldap 进行身份验证

转载 作者:行者123 更新时间:2023-11-30 16:36:24 26 4
gpt4 key购买 nike

由于某些原因,当计算机未加入域时,ldap 和目录服务无法工作。来自 .net 的错误消息是域不可用。有人知道需要做什么吗?

基本...

 domainAndUsername = domain + @"\" + username;
entry = new DirectoryEntry(_path, domainAndUsername, pwd);
entry.AuthenticationType = FindAuthTypeMicrosoft(authType);

...尝试向上面的代码提供 testdomain.com 时,在本地登录到机器时似乎不起作用。

尽管我可以毫无问题地 ping testdomain.com。有什么不同或问题?

最佳答案

这段代码过去对我有用(尽管我承认我现在无法测试它):

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();

最困难的部分(无论如何对我来说)是找出“连接字符串”的细节。我一般靠ADSI EditAD Explorer帮助我找出正确的值是什么。 Softerra LDAP Browser - 免费版本有点旧,v2.6,隐藏在他们的下载部分。

关于c# - 如何在未使用 c# 加入 Microsoft Active Directory 中的域时对 ldap 进行身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/853349/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com