【发布时间】:2014-09-25 16:26:30
【问题描述】:
我是 LDAP 和活动目录身份验证的新手,我只是研究了一些关于 LDAP 身份验证的东西并使用示例应用程序完成了
我只是检查用户是否存在于 ActiveDirectory 中
public static bool DoesUserExist()
{
using (var domainContext = new PrincipalContext(ContextType.Domain,Environment.UserDomainName))
{
using (var foundUser = UserPrincipal.FindByIdentity(domainContext, IdentityType.SamAccountName, Environment.UserName))
{
return foundUser != null;
}
}
}
在我们的本地系统中它工作正常,但是当我托管在 ActiveDirectory Server 中并且我尝试使用服务器 IP 地址访问它时,我遇到了一些问题,例如
ContextType.Domain,Environment.UserDomainName and Environment.UserName
因为这三个值来自服务器信息而不是访问此应用程序的用户
所以请帮助我如何获取用户信息(谁访问此应用程序),以便我需要将这些信息传递给服务器并需要检查用户是否是 activedirectory 用户
【问题讨论】:
-
这是一个 ASP.NET 应用程序吗?
-
是... ActiveDirectory 身份验证使用 LDAP