Error1:发生操作错误。
错误 2:尝试检索授权组时,发生错误 (110)。
public static bool CheckGroupMembership(string userID, string groupName, string domain)
{
bool isMember = false;
// Get an error here, so then I use my username/password and it works...
PrincipalContext ADDomain = new PrincipalContext(ContextType.Domain, domain);
UserPrincipal oUserPrincipal = UserPrincipal.FindByIdentity(ADDomain, userID);
PrincipalSearchResult<Principal> oPrincipalSearchResult = oUserPrincipal.GetAuthorizationGroups(); //<-- Error is here:
foreach (Principal oResult in oPrincipalSearchResult)
{
if (oResult.Name.ToLower().Trim() == groupName.ToLower().Trim())
{
isMember = true;
}
}
return isMember;
}
当我在同一台机器上调试时,这一切都有效,只有当我从远程服务器上拉网页时才会失败。