0
我有一个关于Active Directory的问题。我的项目已被托管在一台服务器上。活动目录已在另一台服务器上维护。现在,我需要在员工登录时在我的应用程序中使用AD身份验证。由于我无法获取ACtive Directory的记录,所以在使用这两种不同的服务时我完全困惑;我已经使用的代码是:Asp.net中的Active Directory C#
string principal = this.Context.User.Identity.Name;
string filter = string.Format("(&(ObjectClass=dev)(sAMAccountName={1}))", "dev", principal);
string domain = "SOFTWARESERVER";
string[] properties = new string[] { "fullname","mail","sn" };
System.Security.Principal.WindowsIdentity wi = System.Security.Principal.WindowsIdentity.GetCurrent();
string[] a = Context.User.Identity.Name.Split('\\');
DirectoryEntry ADEntry = new DirectoryEntry("LDAP://SOFTWARESERVER/DC=softageenapl,DC=com,DC=np");
DirectorySearcher searcher = new DirectorySearcher(ADEntry);
searcher.SearchScope = SearchScope.Subtree;
searcher.ReferralChasing = ReferralChasingOption.All;
searcher.PropertiesToLoad.AddRange(properties);
searcher.Filter = filter;
SearchResult result = searcher.FindOne();
DirectoryEntry directoryEntry = result.GetDirectoryEntry();
string Name = ADEntry.Properties["Fullname"].Value.ToString();
string displayName = directoryEntry.Properties["displayName"][0].ToString();
string firstName = directoryEntry.Properties["givenName"][0].ToString();
string lastName = directoryEntry.Properties["sn"][0].ToString();
string email = directoryEntry.Properties["mail"][0].ToString();
你可以编辑你的问题......它不是明确你真正想做什么,你现在有2个服务器,你需要进行身份验证? – balexandre
其实这是我的客户需求让我的头。我在一台名为链接服务器的服务器上托管了项目,项目在数据库中比较用户名和密码的表单身份验证模式下正常工作。但客户端请求使用Active Directory身份验证,并且此AD已在另一台名为Fileserver的服务器中维护。现在,如何在使用AD身份验证帮助登录系统时验证用户身份..... – Nhuren
如果我可以访问AD文件服务器中用户的邮件地址,以便在计划托管的链接服务器上进行身份验证(另一台服务器),它会为我解决...所以任何解决方案 – Nhuren