Exemple #1
0
        public static bool IsADomainAccount(NTAccount userAccount)
        {
            if (userAccount == null)
            {
                return(false);
            }

            SecurityIdentifier sid;

            try
            {
                sid = UserAccountHelper.GetSecurityIdentifier(userAccount);
            }
            catch (Exception e)
            {
                return(false);
            }

            if (UserAccountHelper.IsLocalAccount(sid) || (UserAccountHelper.IsBuiltInGroup(sid)))
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        public static SecurityIdentifier GetSecurityIdentifier(string accountName)
        {
            AppAssert.Assert(!string.IsNullOrEmpty(accountName));

            // Check if the string is null or empty - these are not valid account names
            if (string.IsNullOrEmpty(accountName))
            {
                throw new IdentityNotMappedException();
            }

            // verify that the entered string is a valid account name
            return(UserAccountHelper.GetSecurityIdentifier(new NTAccount(accountName.Trim())));
        }