我是 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 用户