public static bool UserIsInLocalGroup(string groupName, string userName)
{
if ((object)groupName == null)
throw new ArgumentNullException(nameof(groupName));
if ((object)userName == null)
throw new ArgumentNullException(nameof(userName));
// Remove any irrelevant white space
groupName = groupName.Trim();
userName = userName.Trim();
if (groupName.Length == 0)
throw new ArgumentException("Cannot determine if user is in local group: no group name was specified.", nameof(groupName));
if (userName.Length == 0)
throw new ArgumentException("Cannot determine if user is in local group: no user name was specified.", nameof(userName));
groupName = ValidateGroupName(groupName);
if (Common.IsPosixEnvironment)
return UnixUserInfo.UserIsInLocalGroup(groupName, userName);
return WindowsUserInfo.UserIsInLocalGroup(groupName, userName);
}