在以下代码中
PrincipalContext* context = new PrincipalContext(ContextType::Domain, domainName);
UserPrincipal* user = UserPrincipal::FindByIdentity(context, IdentityType::SamAccountName, userName);
PrincipalSearchResult<Principal*>* groups = user->GetAuthorizationGroups();
我得到以下异常:
消息:对象引用未设置为对象的实例。
异常调用堆栈:
at System.DirectoryServices.AccountManagement.Principal.CheckDisposedOrDeleted()
at System.DirectoryServices.AccountManagement.UserPrincipal.GetAuthorizationGroupsHelper()
at System.DirectoryServices.AccountManagement.UserPrincipal.GetAuthorizationGroups()
知道内部方法失败的原因吗?如何删除或处置用户,或者发生了什么?