// Token: 0x06000DEB RID: 3563 RVA: 0x00029B48 File Offset: 0x00027D48
        internal static SecurityIdentifier GetUserSid(IRecipientSession session, SecurityPrincipalIdParameter user, Task.TaskErrorLoggingDelegate logError, Task.TaskVerboseLoggingDelegate logVerbose)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (logError == null)
            {
                throw new ArgumentNullException("logError");
            }
            if (logVerbose == null)
            {
                throw new ArgumentNullException("logVerbose");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            logVerbose(Strings.CheckIfUserIsASID(user.ToString()));
            SecurityIdentifier securityIdentifier = SecurityPrincipalIdParameter.TryParseToSID(user.RawIdentity);

            if (null != securityIdentifier)
            {
                return(securityIdentifier);
            }
            logVerbose(Strings.LookupUserAsDomainUser(user.ToString()));
            IEnumerable <ADRecipient> objects = user.GetObjects <ADRecipient>(null, session);

            using (IEnumerator <ADRecipient> enumerator = objects.GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    securityIdentifier = ((IADSecurityPrincipal)enumerator.Current).Sid;
                    if (enumerator.MoveNext())
                    {
                        logError(new ManagementObjectAmbiguousException(Strings.ErrorUserNotUnique(user.ToString())), ErrorCategory.InvalidData, null);
                    }
                    return(securityIdentifier);
                }
            }
            securityIdentifier = SecurityPrincipalIdParameter.GetUserSidAsSAMAccount(user, logError, logVerbose);
            if (null == securityIdentifier)
            {
                logError(new ManagementObjectNotFoundException(Strings.ErrorUserNotFound(user.ToString())), ErrorCategory.InvalidData, null);
            }
            return(securityIdentifier);
        }
        // Token: 0x06000DF0 RID: 3568 RVA: 0x00029D70 File Offset: 0x00027F70
        internal static SecurityIdentifier GetUserSidAsSAMAccount(SecurityPrincipalIdParameter user, Task.TaskErrorLoggingDelegate logError, Task.TaskVerboseLoggingDelegate logVerbose)
        {
            SecurityIdentifier securityIdentifier = null;

            if (logVerbose != null)
            {
                logVerbose(Strings.LookupUserAsSAMAccount(user.ToString()));
            }
            NTAccount ntaccount;

            try
            {
                ntaccount = new NTAccount(user.RawIdentity);
            }
            catch (ArgumentException)
            {
                if (logVerbose != null)
                {
                    logVerbose(Strings.UserNotSAMAccount(user.ToString()));
                }
                return(null);
            }
            try
            {
                securityIdentifier = (SecurityIdentifier)ntaccount.Translate(typeof(SecurityIdentifier));
            }
            catch (IdentityNotMappedException)
            {
            }
            catch (SystemException innerException)
            {
                if (logError != null)
                {
                    logError(new LocalizedException(Strings.ForeignForestTrustFailedException(user.ToString()), innerException), ErrorCategory.InvalidOperation, null);
                }
                return(null);
            }
            if (securityIdentifier == null)
            {
                securityIdentifier = SecurityPrincipalIdParameter.MapAliasToSid(user.RawIdentity);
            }
            return(securityIdentifier);
        }
        // Token: 0x06000DEA RID: 3562 RVA: 0x00029A2C File Offset: 0x00027C2C
        internal static IADSecurityPrincipal GetSecurityPrincipal(IRecipientSession session, SecurityPrincipalIdParameter user, Task.TaskErrorLoggingDelegate logError, Task.TaskVerboseLoggingDelegate logVerbose)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (user == null)
            {
                throw new ArgumentNullException("user");
            }
            if (logError == null)
            {
                throw new ArgumentNullException("logError");
            }
            if (logVerbose == null)
            {
                throw new ArgumentNullException("logVerbose");
            }
            ADRecipient adrecipient = null;

            logVerbose(Strings.CheckIfUserIsASID(user.ToString()));
            SecurityIdentifier securityIdentifier = SecurityPrincipalIdParameter.TryParseToSID(user.RawIdentity);

            if (null == securityIdentifier)
            {
                securityIdentifier = SecurityPrincipalIdParameter.GetUserSidAsSAMAccount(user, logError, logVerbose);
            }
            IEnumerable <ADRecipient> objects = user.GetObjects <ADRecipient>(null, session);

            foreach (ADRecipient adrecipient2 in objects)
            {
                if (adrecipient == null)
                {
                    adrecipient = adrecipient2;
                }
                else
                {
                    logError(new ManagementObjectAmbiguousException(Strings.ErrorUserNotUnique(user.ToString())), ErrorCategory.InvalidData, null);
                }
            }
            if (adrecipient == null && null != securityIdentifier)
            {
                adrecipient = new ADUser();
                adrecipient.propertyBag.SetField(IADSecurityPrincipalSchema.Sid, securityIdentifier);
            }
            if (adrecipient == null)
            {
                logError(new ManagementObjectNotFoundException(Strings.ErrorUserNotFound(user.ToString())), ErrorCategory.InvalidData, null);
            }
            return((IADSecurityPrincipal)adrecipient);
        }