// Token: 0x060008DD RID: 2269 RVA: 0x0001F14C File Offset: 0x0001D34C
        private static bool IsValidFqdn(string fqdnString)
        {
            bool result = false;

            if (!string.IsNullOrEmpty(fqdnString))
            {
                if (fqdnString.EndsWith("."))
                {
                    fqdnString = fqdnString.Substring(0, fqdnString.Length - 1);
                }
                string[] array = fqdnString.Split(new char[]
                {
                    '.'
                });
                result = (array.Length > 1);
                foreach (string nameString in array)
                {
                    if (!ServerIdParameter.IsValidName(nameString))
                    {
                        result = false;
                        break;
                    }
                }
            }
            return(result);
        }
        // Token: 0x060008D9 RID: 2265 RVA: 0x0001EEA8 File Offset: 0x0001D0A8
        internal static bool HasRole(ADObjectId identity, ServerRole role, IConfigDataProvider session)
        {
            ServerIdParameter serverIdParameter = new ServerIdParameter(identity.DescendantDN(8));

            ServerInfo[] serverInfo = serverIdParameter.GetServerInfo(session);
            return(serverInfo != null && serverInfo.Length == 1 && (serverInfo[0].Role & role) != ServerRole.None);
        }
 // Token: 0x060008BF RID: 2239 RVA: 0x0001EBF1 File Offset: 0x0001CDF1
 protected ClientAccessArrayIdParameter(string identity) : base(identity)
 {
     if (base.InternalADObjectId != null)
     {
         return;
     }
     this.fqdn = ServerIdParameter.Parse(identity).Fqdn;
 }
        // Token: 0x06000A34 RID: 2612 RVA: 0x00021EB4 File Offset: 0x000200B4
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            IEnumerable <T>       enumerable        = null;
            EnumerableWrapper <T> enumerableWrapper = null;

            notFoundReason = null;
            if (string.IsNullOrEmpty(this.storageGroupName))
            {
                enumerableWrapper = EnumerableWrapper <T> .GetWrapper(base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason));
            }
            if (!string.IsNullOrEmpty(base.CommonName) && (enumerableWrapper == null || !enumerableWrapper.HasElements()))
            {
                string            serverName        = this.storageGroupName;
                ServerIdParameter serverIdParameter = base.ServerId;
                if (string.IsNullOrEmpty(this.storageGroupName))
                {
                    serverName        = base.ServerName;
                    serverIdParameter = new ServerIdParameter();
                }
                ADObjectId[] matchingIdentities = serverIdParameter.GetMatchingIdentities((IConfigDataProvider)session);
                for (int i = 0; i < matchingIdentities.Length; i++)
                {
                    if (ServerIdParameter.HasRole(matchingIdentities[i], this.RoleRestriction, (IConfigDataProvider)session) || (base.AllowLegacy && !ServerIdParameter.HasRole(matchingIdentities[i], ServerRole.All, (IConfigDataProvider)session)))
                    {
                        if (string.IsNullOrEmpty(this.storageGroupName))
                        {
                            rootId     = matchingIdentities[i].GetChildId("InformationStore").GetChildId(serverName);
                            enumerable = base.PerformPrimarySearch <T>(base.CreateWildcardOrEqualFilter(ADObjectSchema.Name, base.CommonName), rootId, session, true, optionalData);
                        }
                        else
                        {
                            List <T> list = new List <T>();
                            IEnumerable <StorageGroup> enumerable2 = base.PerformSearch <StorageGroup>(base.CreateWildcardOrEqualFilter(ADObjectSchema.Name, this.storageGroupName), matchingIdentities[i], session, true);
                            foreach (StorageGroup storageGroup in enumerable2)
                            {
                                enumerable = base.PerformPrimarySearch <T>(base.CreateWildcardOrEqualFilter(ADObjectSchema.Name, base.CommonName), storageGroup.Id, session, true, optionalData);
                                list.AddRange(enumerable);
                            }
                            enumerable = list;
                        }
                    }
                }
            }
            else
            {
                enumerable = enumerableWrapper;
            }
            if (enumerable == null)
            {
                enumerable = new List <T>();
            }
            return(enumerable);
        }
        // Token: 0x060008D4 RID: 2260 RVA: 0x0001EDC8 File Offset: 0x0001CFC8
        protected ServerIdParameter(string identity) : base(identity)
        {
            if (base.InternalADObjectId != null)
            {
                return;
            }
            LegacyDN legacyDN;

            if (!ADObjectNameHelper.ReservedADNameStringRegex.IsMatch(identity) && !ServerIdParameter.IsValidName(identity) && !ServerIdParameter.IsValidFqdn(identity) && !LegacyDN.TryParse(identity, out legacyDN))
            {
                throw new ArgumentException(Strings.ErrorInvalidIdentity(identity), "identity");
            }
            this.fqdn = identity;
            if (identity.EndsWith(".", StringComparison.Ordinal))
            {
                this.fqdn = identity.Substring(0, identity.Length - 1);
            }
        }
Ejemplo n.º 6
0
        // Token: 0x06000450 RID: 1104 RVA: 0x0000F440 File Offset: 0x0000D640
        public static Server GetMailboxServer(ServerIdParameter serverIdParameter, ITopologyConfigurationSession configurationSession, Task.ErrorLoggerDelegate errorHandler)
        {
            if (serverIdParameter == null)
            {
                throw new ArgumentNullException("serverIdParameter");
            }
            if (configurationSession == null)
            {
                throw new ArgumentNullException("serverIdParameter");
            }
            if (errorHandler == null)
            {
                throw new ArgumentNullException("errorHandler");
            }
            IEnumerable <Server> objects = serverIdParameter.GetObjects <Server>(null, configurationSession);
            Server server = null;

            using (IEnumerator <Server> enumerator = objects.GetEnumerator())
            {
                if (!enumerator.MoveNext())
                {
                    errorHandler(new ManagementObjectNotFoundException(Strings.ErrorServerNotFound(serverIdParameter.ToString())), ExchangeErrorCategory.Client, null);
                    return(null);
                }
                server = enumerator.Current;
                if (enumerator.MoveNext())
                {
                    errorHandler(new ManagementObjectAmbiguousException(Strings.ErrorServerNotUnique(serverIdParameter.ToString())), ExchangeErrorCategory.Client, null);
                    return(null);
                }
            }
            if (!server.IsExchange2007OrLater)
            {
                errorHandler(new TaskInvalidOperationException(Strings.ExceptionLegacyObjects(serverIdParameter.ToString())), ExchangeErrorCategory.Context, null);
                return(null);
            }
            if (!server.IsMailboxServer)
            {
                errorHandler(new TaskInvalidOperationException(Strings.ErrorNotMailboxServer(serverIdParameter.ToString())), ExchangeErrorCategory.Client, null);
                return(null);
            }
            return(server);
        }
Ejemplo n.º 7
0
 // Token: 0x06000A2A RID: 2602 RVA: 0x00021D10 File Offset: 0x0001FF10
 protected virtual void Initialize(string identity)
 {
     if (base.InternalADObjectId != null && base.InternalADObjectId.Rdn != null)
     {
         return;
     }
     string[] array = identity.Split(new char[]
     {
         '\\'
     });
     if (array.Length > 2)
     {
         throw new ArgumentException(Strings.ErrorInvalidIdentity(identity), "Identity");
     }
     if (array.Length == 2)
     {
         this.serverName = array[0];
         this.CommonName = array[1];
     }
     else if (array.Length == 1)
     {
         this.serverName = ServerBasedIdParameter.LocalServerFQDN;
         this.CommonName = array[0];
     }
     if (string.IsNullOrEmpty(this.serverName) || string.IsNullOrEmpty(this.CommonName))
     {
         throw new ArgumentException(Strings.ErrorInvalidIdentity(identity), "Identity");
     }
     try
     {
         this.serverId = ServerIdParameter.Parse(this.serverName);
     }
     catch (ArgumentException)
     {
     }
 }
Ejemplo n.º 8
0
 // Token: 0x060009B7 RID: 2487 RVA: 0x000210B4 File Offset: 0x0001F2B4
 public ExchangeCertificateIdParameter(string id)
 {
     if (id == null)
     {
         throw new ArgumentNullException("identity");
     }
     if (id.Length == 0)
     {
         throw new ArgumentException(Strings.ErrorEmptyParameter(base.GetType().ToString()), "identity");
     }
     if (!id.Contains("\\"))
     {
         this.Thumbprint = id;
         return;
     }
     this.Thumbprint = id.Remove(0, id.Split(new char[]
     {
         '\\'
     })[0].Length + 1);
     this.ServerIdParameter = ServerIdParameter.Parse(id.Split(new char[]
     {
         '\\'
     })[0]);
 }
Ejemplo n.º 9
0
        // Token: 0x06000A29 RID: 2601 RVA: 0x00021A8C File Offset: 0x0001FC8C
        internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason)
        {
            IEnumerable <T> enumerable = null;
            List <T>        list       = new List <T>();

            notFoundReason = null;
            int num  = 0;
            int num2 = 0;

            if (base.InternalADObjectId != null)
            {
                enumerable = base.GetADObjectIdObjects <T>(base.InternalADObjectId, rootId, subTreeSession, optionalData);
            }
            EnumerableWrapper <T> wrapper = EnumerableWrapper <T> .GetWrapper(enumerable);

            if (wrapper.HasElements())
            {
                using (IEnumerator <T> enumerator = wrapper.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        T item = enumerator.Current;
                        if (ServerIdParameter.HasRole((ADObjectId)item.Identity, this.RoleRestriction, (IConfigDataProvider)session) || (this.AllowLegacy && !ServerIdParameter.HasRole((ADObjectId)item.Identity, ServerRole.All, (IConfigDataProvider)session)))
                        {
                            list.Add(item);
                        }
                        else if (!ServerIdParameter.HasRole((ADObjectId)item.Identity, ServerRole.All, (IConfigDataProvider)session))
                        {
                            num2++;
                        }
                        else
                        {
                            num++;
                        }
                    }
                    goto IL_21B;
                }
            }
            if (!string.IsNullOrEmpty(this.CommonName) && this.ServerId != null)
            {
                ADObjectId[] matchingIdentities = this.ServerId.GetMatchingIdentities((IConfigDataProvider)session);
                foreach (ADObjectId rootId2 in matchingIdentities)
                {
                    enumerable = base.GetObjectsInOrganization <T>(this.CommonName, rootId2, session, optionalData);
                    foreach (T item2 in enumerable)
                    {
                        if (ServerIdParameter.HasRole((ADObjectId)item2.Identity, this.RoleRestriction, (IConfigDataProvider)session) || (this.AllowLegacy && !ServerIdParameter.HasRole((ADObjectId)item2.Identity, ServerRole.All, (IConfigDataProvider)session)))
                        {
                            list.Add(item2);
                        }
                        else if (!ServerIdParameter.HasRole((ADObjectId)item2.Identity, ServerRole.All, (IConfigDataProvider)session))
                        {
                            num2++;
                        }
                        else
                        {
                            num++;
                        }
                    }
                }
            }
IL_21B:
            if (list.Count == 0)
            {
                if (num2 != 0)
                {
                    notFoundReason = new LocalizedString?(Strings.ExceptionLegacyObjects(this.ToString()));
                }
                if (num != 0)
                {
                    notFoundReason = new LocalizedString?(Strings.ExceptionRoleNotFoundObjects(this.ToString()));
                }
            }
            return(list);
        }