// Token: 0x06000DF7 RID: 3575 RVA: 0x00029FF0 File Offset: 0x000281F0
        private IEnumerable <T> GetUserAccountFromSid <T>(SecurityIdentifier sid, string user, Task.TaskErrorLoggingDelegate logError, ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) where T : IConfigurable, new()
        {
            notFoundReason = null;
            string userAccountNameFromSid = SecurityPrincipalIdParameter.GetUserAccountNameFromSid(sid, user, logError);

            if (!string.IsNullOrEmpty(userAccountNameFromSid))
            {
                SecurityPrincipalIdParameter securityPrincipalIdParameter = this.CreateSidParameter(userAccountNameFromSid);
                return(securityPrincipalIdParameter.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            }
            return(null);
        }
        // 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);
        }
        // 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);
        }
Пример #4
0
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));

            if (wrapper.HasElements())
            {
                return(wrapper);
            }
            SecurityPrincipalIdParameter securityPrincipalIdParameter = new SecurityPrincipalIdParameter(base.RawIdentity);
            OptionalIdentityData         optionalIdentityData         = (optionalData == null) ? new OptionalIdentityData() : optionalData.Clone();

            optionalIdentityData.AdditionalFilter = QueryFilter.AndTogether(new QueryFilter[]
            {
                optionalIdentityData.AdditionalFilter,
                RecipientIdParameter.GetRecipientTypeFilter(this.RecipientTypes)
            });
            return(securityPrincipalIdParameter.GetObjects <T>(rootId, session, subTreeSession, optionalIdentityData, out notFoundReason));
        }