Example #1
0
 public static GlobalCatalogCollection FindAll(DirectoryContext context, string siteName)
 {
     if (context != null)
     {
         if (context.ContextType == DirectoryContextType.Forest)
         {
             if (siteName != null)
             {
                 context = new DirectoryContext(context);
                 return(GlobalCatalog.FindAllInternal(context, siteName));
             }
             else
             {
                 throw new ArgumentNullException("siteName");
             }
         }
         else
         {
             throw new ArgumentException(Res.GetString("TargetShouldBeForest"), "context");
         }
     }
     else
     {
         throw new ArgumentNullException("context");
     }
 }
Example #2
0
 public static GlobalCatalog FindOne(DirectoryContext context, string siteName, LocatorOptions flag)
 {
     if (context != null)
     {
         if (context.ContextType == DirectoryContextType.Forest)
         {
             if (siteName != null)
             {
                 return(GlobalCatalog.FindOneWithCredentialValidation(context, siteName, flag));
             }
             else
             {
                 throw new ArgumentNullException("siteName");
             }
         }
         else
         {
             throw new ArgumentException(Res.GetString("TargetShouldBeForest"), "context");
         }
     }
     else
     {
         throw new ArgumentNullException("context");
     }
 }
        internal static GlobalCatalog FindOneWithCredentialValidation(DirectoryContext context, string siteName, LocatorOptions flag)
        {
            bool flag2 = false;
            bool flag3 = false;

            context = new DirectoryContext(context);
            GlobalCatalog dc = FindOneInternal(context, context.Name, siteName, flag);

            try
            {
                DomainController.ValidateCredential(dc, context);
                flag3 = true;
            }
            catch (COMException exception)
            {
                if (exception.ErrorCode != -2147016646)
                {
                    throw ExceptionHelper.GetExceptionFromCOMException(context, exception);
                }
                if ((flag & LocatorOptions.ForceRediscovery) != 0L)
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString("GCNotFoundInForest", new object[] { context.Name }), typeof(GlobalCatalog), null);
                }
                flag2 = true;
            }
            finally
            {
                if (!flag3)
                {
                    dc.Dispose();
                }
            }
            if (flag2)
            {
                flag3 = false;
                dc    = FindOneInternal(context, context.Name, siteName, flag | LocatorOptions.ForceRediscovery);
                try
                {
                    DomainController.ValidateCredential(dc, context);
                    flag3 = true;
                }
                catch (COMException exception2)
                {
                    if (exception2.ErrorCode == -2147016646)
                    {
                        throw new ActiveDirectoryObjectNotFoundException(Res.GetString("GCNotFoundInForest", new object[] { context.Name }), typeof(GlobalCatalog), null);
                    }
                    throw ExceptionHelper.GetExceptionFromCOMException(context, exception2);
                }
                finally
                {
                    if (!flag3)
                    {
                        dc.Dispose();
                    }
                }
            }
            return(dc);
        }
    public int IndexOf(GlobalCatalog globalCatalog)
    {
      Contract.Requires(globalCatalog != null);
      Contract.Ensures(Contract.Result<int>() >= 0);
      Contract.Ensures(Contract.Result<int>() < this.Count);

      return default(int);
    }
Example #5
0
        public int IndexOf(GlobalCatalog globalCatalog)
        {
            Contract.Requires(globalCatalog != null);
            Contract.Ensures(Contract.Result <int>() >= 0);
            Contract.Ensures(Contract.Result <int>() < this.Count);

            return(default(int));
        }
 public GlobalCatalogCollection FindAllGlobalCatalogs(string siteName)
 {
     this.CheckIfDisposed();
     if (siteName == null)
     {
         throw new ArgumentNullException("siteName");
     }
     return(GlobalCatalog.FindAllInternal(this.context, siteName));
 }
 public GlobalCatalog FindGlobalCatalog(string siteName, LocatorOptions flag)
 {
     this.CheckIfDisposed();
     if (siteName == null)
     {
         throw new ArgumentNullException("siteName");
     }
     return(GlobalCatalog.FindOneInternal(this.context, this.Name, siteName, flag));
 }
Example #8
0
        public GlobalCatalog FindGlobalCatalog(string siteName)
        {
            CheckIfDisposed();

            if (siteName == null)
            {
                throw new ArgumentNullException(nameof(siteName));
            }

            return(GlobalCatalog.FindOneInternal(_context, Name, siteName, 0));
        }
        public int IndexOf(GlobalCatalog globalCatalog)
        {
            if (globalCatalog == null)
                throw new ArgumentNullException("globalCatalog");

            for (int i = 0; i < InnerList.Count; i++)
            {
                GlobalCatalog tmp = (GlobalCatalog)InnerList[i];
                if (Utils.Compare(tmp.Name, globalCatalog.Name) == 0)
                {
                    return i;
                }
            }
            return -1;
        }
Example #10
0
        public bool Contains(GlobalCatalog globalCatalog)
        {
            if (globalCatalog == null)
                throw new ArgumentNullException("globalCatalog");

            for (int i = 0; i < InnerList.Count; i++)
            {
                GlobalCatalog tmp = (GlobalCatalog)InnerList[i];
                if (Utils.Compare(tmp.Name, globalCatalog.Name) == 0)
                {
                    return true;
                }
            }
            return false;
        }
 public int IndexOf(GlobalCatalog globalCatalog)
 {
     if (globalCatalog == null)
     {
         throw new ArgumentNullException("globalCatalog");
     }
     for (int i = 0; i < base.InnerList.Count; i++)
     {
         GlobalCatalog catalog = (GlobalCatalog)base.InnerList[i];
         if (Utils.Compare(catalog.Name, globalCatalog.Name) == 0)
         {
             return(i);
         }
     }
     return(-1);
 }
 public bool Contains(GlobalCatalog globalCatalog)
 {
     if (globalCatalog == null)
     {
         throw new ArgumentNullException("globalCatalog");
     }
     for (int i = 0; i < base.InnerList.Count; i++)
     {
         GlobalCatalog catalog = (GlobalCatalog)base.InnerList[i];
         if (Utils.Compare(catalog.Name, globalCatalog.Name) == 0)
         {
             return(true);
         }
     }
     return(false);
 }
Example #13
0
        public int IndexOf(GlobalCatalog globalCatalog)
        {
            if (globalCatalog == null)
            {
                throw new ArgumentNullException(nameof(globalCatalog));
            }

            for (int i = 0; i < InnerList.Count; i++)
            {
                GlobalCatalog tmp = (GlobalCatalog)InnerList[i];
                if (Utils.Compare(tmp.Name, globalCatalog.Name) == 0)
                {
                    return(i);
                }
            }
            return(-1);
        }
Example #14
0
        public bool Contains(GlobalCatalog globalCatalog)
        {
            if (globalCatalog == null)
            {
                throw new ArgumentNullException(nameof(globalCatalog));
            }

            for (int i = 0; i < InnerList.Count; i++)
            {
                GlobalCatalog tmp = (GlobalCatalog)InnerList[i] !;
                if (Utils.Compare(tmp.Name, globalCatalog.Name) == 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #15
0
        //if we can find a GC to talk to, return that GC, if not, return null
        public static GlobalCatalog GetGlobalCatalog(DirectoryContext dc)
        {
            GlobalCatalog gc;

            bool gcEnabled = true;

            //using dc.Name to query RootDSE

            /* string sPath = string.Format("LDAP://{0}/RootDSE", dc.Name);
             * DirectoryEntry rootDse = new DirectoryEntry(sPath, dc.UserName,dc.Password);
             * bool gcEnabled = false;
             * //gcEnabled = (bool)rootDse.Properties["isGlobalCatalogReady"].Value;
             * string ntdsdsaPath = string.Format("LDAP://{0}/{1}/", dc.Name, rootDse.Properties["configurationNamingContext"].Value.ToString());
             * Console.WriteLine("ntdsdsaPath is " + ntdsdsaPath);
             * DirectorySearcher ds = new DirectorySearcher(new DirectoryEntry(ntdsdsaPath, dc.UserName, dc.Password));
             * ds.Filter = "(&(objectcategory=ntdsdsa)(options=1))";
             * ds.SearchScope = SearchScope.Subtree;
             * SearchResultCollection src = ds.FindAll();
             * if (src != null && src.Count > 0)
             *   gcEnabled = true;                */

            if (gcEnabled)
            {
                gc      = new GlobalCatalog();
                gc.DC   = dc;
                gc.Name = dc.Name;
                IPHostEntry ipHostEntry = Dns.GetHostEntry(gc.Name);
                gc.IPAddress = ipHostEntry.AddressList[0].ToString();
            }
            else
            {
                gc = null; //can't find a global catalog to talk to
                //Console.WriteLine("Cannot find a GC to talk to.");
            }

            return(gc);
        }
Example #16
0
		public int IndexOf(GlobalCatalog globalCatalog)
		{
			if (globalCatalog != null)
			{
				int num = 0;
				while (num < base.InnerList.Count)
				{
					GlobalCatalog item = (GlobalCatalog)base.InnerList[num];
					if (Utils.Compare(item.Name, globalCatalog.Name) != 0)
					{
						num++;
					}
					else
					{
						return num;
					}
				}
				return -1;
			}
			else
			{
				throw new ArgumentNullException("globalCatalog");
			}
		}
 public int IndexOf(GlobalCatalog globalCatalog)
 {
     if (globalCatalog != null)
     {
         int num = 0;
         while (num < base.InnerList.Count)
         {
             GlobalCatalog item = (GlobalCatalog)base.InnerList[num];
             if (Utils.Compare(item.Name, globalCatalog.Name) != 0)
             {
                 num++;
             }
             else
             {
                 return(num);
             }
         }
         return(-1);
     }
     else
     {
         throw new ArgumentNullException("globalCatalog");
     }
 }
Example #18
0
		public void CopyTo(GlobalCatalog[] globalCatalogs, int index)
		{
			base.InnerList.CopyTo(globalCatalogs, index);
		}
Example #19
0
 public int IndexOf(GlobalCatalog globalCatalog)
 {
     throw new NotImplementedException();
 }
Example #20
0
        public GlobalCatalog FindGlobalCatalog(LocatorOptions flag)
        {
            CheckIfDisposed();

            return(GlobalCatalog.FindOneInternal(_context, Name, null, flag));
        }
 public void CopyTo(GlobalCatalog[] globalCatalogs, int index)
 {
   Contract.Requires(globalCatalogs != null);
   Contract.Requires(index >=0);
 }
Example #22
0
        public bool Contains(GlobalCatalog globalCatalog)
        {
            Contract.Requires(globalCatalog != null);

            return(default(bool));
        }
 public GlobalCatalog FindGlobalCatalog()
 {
     this.CheckIfDisposed();
     return(GlobalCatalog.FindOneInternal(this.context, this.Name, null, 0L));
 }
Example #24
0
 public bool Contains(GlobalCatalog globalCatalog)
 {
     throw new NotImplementedException();
 }
        //if we can find a GC to talk to, return that GC, if not, return null
        public static GlobalCatalog GetGlobalCatalog(DirectoryContext dc)
        {
            GlobalCatalog gc;

            bool gcEnabled = true;

            //using dc.Name to query RootDSE
           /* string sPath = string.Format("LDAP://{0}/RootDSE", dc.Name);
            DirectoryEntry rootDse = new DirectoryEntry(sPath, dc.UserName,dc.Password);
            bool gcEnabled = false;
            //gcEnabled = (bool)rootDse.Properties["isGlobalCatalogReady"].Value;
            string ntdsdsaPath = string.Format("LDAP://{0}/{1}/", dc.Name, rootDse.Properties["configurationNamingContext"].Value.ToString());
            Console.WriteLine("ntdsdsaPath is " + ntdsdsaPath);
            DirectorySearcher ds = new DirectorySearcher(new DirectoryEntry(ntdsdsaPath, dc.UserName, dc.Password));
            ds.Filter = "(&(objectcategory=ntdsdsa)(options=1))";
            ds.SearchScope = SearchScope.Subtree;
            SearchResultCollection src = ds.FindAll();
            if (src != null && src.Count > 0)
                gcEnabled = true;                */

            if (gcEnabled)
            {
                gc = new GlobalCatalog();
                gc.DC = dc;
                gc.Name = dc.Name;
                IPHostEntry ipHostEntry = Dns.GetHostEntry(gc.Name);
                gc.IPAddress = ipHostEntry.AddressList[0].ToString();
            }
            else
            {
                gc = null; //can't find a global catalog to talk to
                //Console.WriteLine("Cannot find a GC to talk to.");
            }

            return gc;
        }
Example #26
0
        public GlobalCatalog FindGlobalCatalog()
        {
            CheckIfDisposed();

            return(GlobalCatalog.FindOneInternal(_context, Name, null, 0));
        }
    public bool Contains(GlobalCatalog globalCatalog)
    {
      Contract.Requires(globalCatalog != null);

      return default(bool);
    }
Example #28
0
		public bool Contains (GlobalCatalog globalCatalog)
		{
			throw new NotImplementedException ();
		}
Example #29
0
        public GlobalCatalogCollection FindAllGlobalCatalogs()
        {
            CheckIfDisposed();

            return(GlobalCatalog.FindAllInternal(_context, null));
        }
Example #30
0
		public int IndexOf (GlobalCatalog globalCatalog)
		{
			throw new NotImplementedException ();
		}
Example #31
0
		public void CopyTo (GlobalCatalog[] globalCatalogs, int index)
		{
			throw new NotImplementedException ();
		}
Example #32
0
        internal static GlobalCatalog FindOneWithCredentialValidation(DirectoryContext context, string siteName, LocatorOptions flag)
        {
            bool flag1 = false;
            bool flag2 = false;

            context = new DirectoryContext(context);
            GlobalCatalog globalCatalog = GlobalCatalog.FindOneInternal(context, context.Name, siteName, flag);

            using (globalCatalog)
            {
                if (flag2)
                {
                    try
                    {
                        DomainController.ValidateCredential(globalCatalog, context);
                    }
                    catch (COMException cOMException1)
                    {
                        COMException cOMException = cOMException1;
                        if (cOMException.ErrorCode != -2147016646)
                        {
                            throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException);
                        }
                        else
                        {
                            if ((flag & LocatorOptions.ForceRediscovery) != 0)
                            {
                                object[] name = new object[1];
                                name[0] = context.Name;
                                throw new ActiveDirectoryObjectNotFoundException(Res.GetString("GCNotFoundInForest", name), typeof(GlobalCatalog), null);
                            }
                            else
                            {
                                flag1 = true;
                            }
                        }
                    }
                }
            }
            if (flag1)
            {
                flag2         = false;
                globalCatalog = GlobalCatalog.FindOneInternal(context, context.Name, siteName, flag | LocatorOptions.ForceRediscovery);
                using (globalCatalog)
                {
                    if (flag2)
                    {
                        try
                        {
                            DomainController.ValidateCredential(globalCatalog, context);
                        }
                        catch (COMException cOMException3)
                        {
                            COMException cOMException2 = cOMException3;
                            if (cOMException2.ErrorCode != -2147016646)
                            {
                                throw ExceptionHelper.GetExceptionFromCOMException(context, cOMException2);
                            }
                            else
                            {
                                object[] objArray = new object[1];
                                objArray[0] = context.Name;
                                throw new ActiveDirectoryObjectNotFoundException(Res.GetString("GCNotFoundInForest", objArray), typeof(GlobalCatalog), null);
                            }
                        }
                    }
                }
            }
            return(globalCatalog);
        }