ユーザーが特定のグループに属している天気を確認しています。私のコードは次のように書かれています
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
この問題の解決策はありますか?