1

在下面的代码中

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()

知道为什么内部方法会失败吗?用户如何被删除或处置,或者发生了什么?

4

0 回答 0