GSF.Identity.UserInfo.RemoveUserFromLocalGroup C# (CSharp) Méthode

RemoveUserFromLocalGroup() public static méthode

Removes an existing user from the specified local groupName.
This function will handle Windows service virtual accounts by specifying the complete virtual account name, such as @"NT SERVICE\MyService", as the userName. This function can also remove Active Directory user accounts and groups from the local group the when the userName is prefixed with a domain name and a backslash "\".
or was null. No or was specified. Could not remove user from local group.
public static RemoveUserFromLocalGroup ( string groupName, string userName ) : bool
groupName string Group name to remove local user from.
userName string Existing local user name.
Résultat bool
        public static bool RemoveUserFromLocalGroup(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 remove user from local group: no group name was specified.", nameof(groupName));

            if (userName.Length == 0)
                throw new ArgumentException("Cannot remove user from local group: no user name was specified.", nameof(userName));

            groupName = ValidateGroupName(groupName);

            if (Common.IsPosixEnvironment)
                return UnixUserInfo.RemoveUserFromLocalGroup(groupName, userName);

            return WindowsUserInfo.RemoveUserFromLocalGroup(groupName, userName);
        }