2
私はユーザーが特定のグループに属している天気をチェックしています。 ローカルグループのメンバーを取得
public static bool IsInGroup(string user, string group)
{
Console.WriteLine("The user name and group name is {0} {1}", user, group); //Check the parameter values
bool result = false;
PrincipalContext context = new PrincipalContext(ContextType.Domain);
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(context,user);
GroupPrincipal groupPrincipal = GroupPrincipal.FindByIdentity(context, group);
if (userPrincipal != null)
{
if (userPrincipal.IsMemberOf(groupPrincipal))
{
result = true;
}
}
return result;
}
を次のように私のコードが書かれているしかし、私はこの問題のいずれかの可能な解決策があります。この
The user name and group name is sampat TestGrp1
Value cannot be null.
Parameter name: group
のように見えるエラーが直面しているのですか?