Esempio n. 1
0
        public void FindOne_InvalidFlag_ThrowsArgumentException(LocatorOptions flag)
        {
            var context = new DirectoryContext(DirectoryContextType.Domain);

            AssertExtensions.Throws <ArgumentException>("flag", () => DomainController.FindOne(context, flag));
            AssertExtensions.Throws <ArgumentException>("flag", () => DomainController.FindOne(context, "siteName", flag));
        }
        private DirectoryServer FindDirectoryServerInternal(string siteName, bool forceRediscovery)
        {
            DomainControllerInfo info;
            LocatorOptions       options = 0L;
            int errorCode = 0;

            if ((siteName != null) && (siteName.Length == 0))
            {
                throw new ArgumentException(Res.GetString("EmptyStringParameter"), "siteName");
            }
            if (!this.committed)
            {
                throw new InvalidOperationException(Res.GetString("CannotPerformOperationOnUncommittedObject"));
            }
            if (forceRediscovery)
            {
                options = LocatorOptions.ForceRediscovery;
            }
            errorCode = Locator.DsGetDcNameWrapper(null, this.dnsName, siteName, options | 0x8000L, out info);
            if (errorCode == 0x54b)
            {
                throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ReplicaNotFound"), typeof(DirectoryServer), null);
            }
            if (errorCode != 0)
            {
                throw ExceptionHelper.GetExceptionFromErrorCode(errorCode);
            }
            string domainControllerName = info.DomainControllerName.Substring(2);

            return(new DomainController(Utils.GetNewDirectoryContext(domainControllerName, DirectoryContextType.DirectoryServer, base.context), domainControllerName));
        }
Esempio n. 3
0
        public GlobalCatalog FindGlobalCatalog(string siteName, LocatorOptions flag)
        {
            Contract.Requires(siteName != null);
            Contract.Ensures(Contract.Result <GlobalCatalog>() != null);

            return(default(GlobalCatalog));
        }
Esempio n. 4
0
        public static GlobalCatalog FindOne(DirectoryContext context, LocatorOptions flag)
        {
            Contract.Requires(context != null);
            Contract.Requires(context.ContextType == DirectoryContextType.Forest);

            Contract.Ensures(Contract.Result <GlobalCatalog>() != null);

            return(default(GlobalCatalog));
        }
 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));
 }
 public static GlobalCatalog FindOne(DirectoryContext context, LocatorOptions flag)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (context.ContextType != DirectoryContextType.Forest)
     {
         throw new ArgumentException(Res.GetString("TargetShouldBeForest"), "context");
     }
     return(FindOneWithCredentialValidation(context, null, flag));
 }
 public static DomainController FindOne(DirectoryContext context, LocatorOptions flag)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (context.ContextType != DirectoryContextType.Domain)
     {
         throw new ArgumentException(Res.GetString("TargetShouldBeDomain"), "context");
     }
     return(FindOneWithCredentialValidation(context, null, flag));
 }
Esempio n. 8
0
        public static new GlobalCatalog FindOne(DirectoryContext context, LocatorOptions flag)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (context.ContextType != DirectoryContextType.Forest)
            {
                throw new ArgumentException(SR.TargetShouldBeForest, nameof(context));
            }

            return(FindOneWithCredentialValidation(context, null, flag));
        }
Esempio n. 9
0
		public DomainController FindDomainController(string siteName, LocatorOptions flag)
		{
			base.CheckIfDisposed();
			if (siteName != null)
			{
				return DomainController.FindOneInternal(this.context, base.Name, siteName, flag);
			}
			else
			{
				throw new ArgumentNullException("siteName");
			}
		}
Esempio n. 10
0
        public static System.DirectoryServices.ActiveDirectory.DomainController FindOne(DirectoryContext context, string siteName, LocatorOptions flag)
        {
            Contract.Requires(context != null);
            Contract.Requires(context.ContextType == DirectoryContextType.Domain);
            Contract.Requires(siteName != null);
            Contract.Ensures(Contract.Result <DomainController>() != null);

            return(default(System.DirectoryServices.ActiveDirectory.DomainController));
        }
	public DomainController FindDomainController(LocatorOptions flag) {}
 public GlobalCatalog FindGlobalCatalog(string siteName, LocatorOptions flag)
 {
 }
 public static GlobalCatalog FindOne(DirectoryContext context, string siteName, LocatorOptions flag)
 {
 }
 public static GlobalCatalog FindOne(DirectoryContext context, string siteName, LocatorOptions flag)
 {
   Contract.Requires(context != null);
   Contract.Requires(context.ContextType == DirectoryContextType.Forest);
   Contract.Requires(siteName != null);
   Contract.Ensures(Contract.Result<GlobalCatalog>() != null);
   
   return default(GlobalCatalog);
 }
    public DomainController FindDomainController(string siteName, LocatorOptions flag)
    {
      Contract.Ensures(Contract.Result<DomainController>() != null);

      return default(DomainController);
    }
Esempio n. 16
0
 public new static GlobalCatalog FindOne(DirectoryContext context, string siteName, LocatorOptions flag)
 {
     throw new NotImplementedException();
 }
Esempio n. 17
0
		public DomainController FindDomainController (string siteName, LocatorOptions flag)
		{
			throw new NotImplementedException ();
		}
Esempio n. 18
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);
        }
Esempio n. 19
0
        internal new static GlobalCatalog FindOneInternal(DirectoryContext context, string forestName, string siteName, LocatorOptions flag)
        {
            DomainControllerInfo domainControllerInfo  = null;
            DomainControllerInfo domainControllerInfo1 = null;
            int num = 0;

            if (siteName == null || siteName.Length != 0)
            {
                if (((int)flag & -23554) == 0)
                {
                    if (forestName == null)
                    {
                        int num1 = Locator.DsGetDcNameWrapper(null, DirectoryContext.GetLoggedOnDomain(), null, (long)16, out domainControllerInfo1);
                        if (num1 != 0x54b)
                        {
                            if (num1 == 0)
                            {
                                forestName = domainControllerInfo1.DnsForestName;
                            }
                            else
                            {
                                throw ExceptionHelper.GetExceptionFromErrorCode(num);
                            }
                        }
                        else
                        {
                            throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ContextNotAssociatedWithDomain"), typeof(GlobalCatalog), null);
                        }
                    }
                    num = Locator.DsGetDcNameWrapper(null, forestName, siteName, (int)flag | 80, out domainControllerInfo);
                    if (num != 0x54b)
                    {
                        if (num != 0x3ec)
                        {
                            if (num == 0)
                            {
                                string           str = domainControllerInfo.DomainControllerName.Substring(2);
                                DirectoryContext newDirectoryContext = Utils.GetNewDirectoryContext(str, DirectoryContextType.DirectoryServer, context);
                                return(new GlobalCatalog(newDirectoryContext, str));
                            }
                            else
                            {
                                throw ExceptionHelper.GetExceptionFromErrorCode(num);
                            }
                        }
                        else
                        {
                            throw new ArgumentException(Res.GetString("InvalidFlags"), "flag");
                        }
                    }
                    else
                    {
                        object[] objArray = new object[1];
                        objArray[0] = forestName;
                        throw new ActiveDirectoryObjectNotFoundException(Res.GetString("GCNotFoundInForest", objArray), typeof(GlobalCatalog), null);
                    }
                }
                else
                {
                    throw new ArgumentException(Res.GetString("InvalidFlags"), "flag");
                }
            }
            else
            {
                throw new ArgumentException(Res.GetString("EmptyStringParameter"), "siteName");
            }
        }
Esempio n. 20
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");
     }
 }
Esempio n. 21
0
        internal static DomainController FindOneInternal(DirectoryContext context, string domainName, string siteName, LocatorOptions flag)
        {
            DomainControllerInfo domainControllerInfo;
            int errorCode = 0;

            if (siteName != null && siteName.Length == 0)
            {
                throw new ArgumentException(Res.GetString(Res.EmptyStringParameter), "siteName");
            }

            // check that the flags passed have only the valid bits set
            if (((long)flag & (~((long)LocatorOptions.AvoidSelf | (long)LocatorOptions.ForceRediscovery | (long)LocatorOptions.KdcRequired | (long)LocatorOptions.TimeServerRequired | (long)LocatorOptions.WriteableRequired))) != 0)
            {
                throw new ArgumentException(Res.GetString(Res.InvalidFlags), "flag");
            }

            if (domainName == null)
            {
                domainName = DirectoryContext.GetLoggedOnDomain();
            }

            // call DsGetDcName
            errorCode = Locator.DsGetDcNameWrapper(null, domainName, siteName, (long)flag | (long)PrivateLocatorFlags.DirectoryServicesRequired, out domainControllerInfo);

            if (errorCode == NativeMethods.ERROR_NO_SUCH_DOMAIN)
            {
                throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DCNotFoundInDomain, domainName), typeof(DomainController), null);
            }
            // this can only occur when flag is being explicitly passed (since the flags that we pass internally are valid)
            if (errorCode == NativeMethods.ERROR_INVALID_FLAGS)
            {
                throw new ArgumentException(Res.GetString(Res.InvalidFlags), "flag");
            }
            else if (errorCode != 0)
            {
                throw ExceptionHelper.GetExceptionFromErrorCode(errorCode);
            }

            // create a DomainController object
            Debug.Assert(domainControllerInfo.DomainControllerName.Length > 2);
            string domainControllerName = domainControllerInfo.DomainControllerName.Substring(2);

            // create a new context object for the domain controller 
            DirectoryContext dcContext = Utils.GetNewDirectoryContext(domainControllerName, DirectoryContextType.DirectoryServer, context);

            return new DomainController(dcContext, domainControllerName);
        }
Esempio n. 22
0
		public GlobalCatalog FindGlobalCatalog (string siteName, LocatorOptions flag)
		{
			throw new NotImplementedException ();
		}
	public GlobalCatalog FindGlobalCatalog(LocatorOptions flag) {}
Esempio n. 24
0
		internal static DomainController FindOneInternal(DirectoryContext context, string domainName, string siteName, LocatorOptions flag)
		{
			DomainControllerInfo domainControllerInfo = null;
			if (siteName == null || siteName.Length != 0)
			{
				if (((int)flag & -23554) == 0)
				{
					if (domainName == null)
					{
						domainName = DirectoryContext.GetLoggedOnDomain();
					}
					int num = Locator.DsGetDcNameWrapper(null, domainName, siteName, (int)flag | 16, out domainControllerInfo);
					if (num != 0x54b)
					{
						if (num != 0x3ec)
						{
							if (num == 0)
							{
								string str = domainControllerInfo.DomainControllerName.Substring(2);
								DirectoryContext newDirectoryContext = Utils.GetNewDirectoryContext(str, DirectoryContextType.DirectoryServer, context);
								return new DomainController(newDirectoryContext, str);
							}
							else
							{
								throw ExceptionHelper.GetExceptionFromErrorCode(num);
							}
						}
						else
						{
							throw new ArgumentException(Res.GetString("InvalidFlags"), "flag");
						}
					}
					else
					{
						object[] objArray = new object[1];
						objArray[0] = domainName;
						throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DCNotFoundInDomain", objArray), typeof(DomainController), null);
					}
				}
				else
				{
					throw new ArgumentException(Res.GetString("InvalidFlags"), "flag");
				}
			}
			else
			{
				throw new ArgumentException(Res.GetString("EmptyStringParameter"), "siteName");
			}
		}
Esempio n. 25
0
		internal new static GlobalCatalog FindOneInternal(DirectoryContext context, string forestName, string siteName, LocatorOptions flag)
		{
			DomainControllerInfo domainControllerInfo = null;
			DomainControllerInfo domainControllerInfo1 = null;
			int num = 0;
			if (siteName == null || siteName.Length != 0)
			{
				if (((int)flag & -23554) == 0)
				{
					if (forestName == null)
					{
						int num1 = Locator.DsGetDcNameWrapper(null, DirectoryContext.GetLoggedOnDomain(), null, (long)16, out domainControllerInfo1);
						if (num1 != 0x54b)
						{
							if (num1 == 0)
							{
								forestName = domainControllerInfo1.DnsForestName;
							}
							else
							{
								throw ExceptionHelper.GetExceptionFromErrorCode(num);
							}
						}
						else
						{
							throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ContextNotAssociatedWithDomain"), typeof(GlobalCatalog), null);
						}
					}
					num = Locator.DsGetDcNameWrapper(null, forestName, siteName, (int)flag | 80, out domainControllerInfo);
					if (num != 0x54b)
					{
						if (num != 0x3ec)
						{
							if (num == 0)
							{
								string str = domainControllerInfo.DomainControllerName.Substring(2);
								DirectoryContext newDirectoryContext = Utils.GetNewDirectoryContext(str, DirectoryContextType.DirectoryServer, context);
								return new GlobalCatalog(newDirectoryContext, str);
							}
							else
							{
								throw ExceptionHelper.GetExceptionFromErrorCode(num);
							}
						}
						else
						{
							throw new ArgumentException(Res.GetString("InvalidFlags"), "flag");
						}
					}
					else
					{
						object[] objArray = new object[1];
						objArray[0] = forestName;
						throw new ActiveDirectoryObjectNotFoundException(Res.GetString("GCNotFoundInForest", objArray), typeof(GlobalCatalog), null);
					}
				}
				else
				{
					throw new ArgumentException(Res.GetString("InvalidFlags"), "flag");
				}
			}
			else
			{
				throw new ArgumentException(Res.GetString("EmptyStringParameter"), "siteName");
			}
		}
Esempio n. 26
0
 public DomainController FindDomainController(string siteName, LocatorOptions flag)
 {
 }
Esempio n. 27
0
        internal static new GlobalCatalog FindOneInternal(DirectoryContext context, string?forestName, string?siteName, LocatorOptions flag)
        {
            DomainControllerInfo domainControllerInfo;
            int errorCode = 0;

            if (siteName != null && siteName.Length == 0)
            {
                throw new ArgumentException(SR.EmptyStringParameter, nameof(siteName));
            }

            // check that the flags passed have only the valid bits set
            if (((long)flag & (~((long)LocatorOptions.AvoidSelf | (long)LocatorOptions.ForceRediscovery | (long)LocatorOptions.KdcRequired | (long)LocatorOptions.TimeServerRequired | (long)LocatorOptions.WriteableRequired))) != 0)
            {
                throw new ArgumentException(SR.InvalidFlags, nameof(flag));
            }

            if (forestName == null)
            {
                // get the dns name of the logged on forest
                DomainControllerInfo tempDomainControllerInfo;
                int error = Locator.DsGetDcNameWrapper(null, DirectoryContext.GetLoggedOnDomain(), null, (long)PrivateLocatorFlags.DirectoryServicesRequired, out tempDomainControllerInfo);

                if (error == NativeMethods.ERROR_NO_SUCH_DOMAIN)
                {
                    // throw not found exception
                    throw new ActiveDirectoryObjectNotFoundException(SR.ContextNotAssociatedWithDomain, typeof(GlobalCatalog), null);
                }
                else if (error != 0)
                {
                    throw ExceptionHelper.GetExceptionFromErrorCode(errorCode);
                }

                Debug.Assert(tempDomainControllerInfo.DnsForestName != null);
                forestName = tempDomainControllerInfo.DnsForestName;
            }

            // call DsGetDcName
            errorCode = Locator.DsGetDcNameWrapper(null, forestName, siteName, (long)flag | (long)(PrivateLocatorFlags.GCRequired | PrivateLocatorFlags.DirectoryServicesRequired), out domainControllerInfo);

            if (errorCode == NativeMethods.ERROR_NO_SUCH_DOMAIN)
            {
                throw new ActiveDirectoryObjectNotFoundException(SR.Format(SR.GCNotFoundInForest, forestName), typeof(GlobalCatalog), null);
            }
            // this can only occur when flag is being explicitly passed (since the flags that we pass internally are valid)
            if (errorCode == NativeMethods.ERROR_INVALID_FLAGS)
            {
                throw new ArgumentException(SR.InvalidFlags, nameof(flag));
            }
            else if (errorCode != 0)
            {
                throw ExceptionHelper.GetExceptionFromErrorCode(errorCode);
            }

            // create a GlobalCatalog object
            // the name is returned in the form "\\servername", so skip the "\\"
            Debug.Assert(domainControllerInfo.DomainControllerName.Length > 2);
            string globalCatalogName = domainControllerInfo.DomainControllerName.Substring(2);

            // create a new context object for the global catalog
            DirectoryContext gcContext = Utils.GetNewDirectoryContext(globalCatalogName, DirectoryContextType.DirectoryServer, context);

            return(new GlobalCatalog(gcContext, globalCatalogName));
        }
Esempio n. 28
0
		public new static GlobalCatalog FindOne (DirectoryContext context, string siteName, LocatorOptions flag)
		{
			throw new NotImplementedException ();
		}
Esempio n. 29
0
		public GlobalCatalog FindGlobalCatalog(string siteName, LocatorOptions flag)
		{
			this.CheckIfDisposed();
			if (siteName != null)
			{
				return GlobalCatalog.FindOneInternal(this.context, this.Name, siteName, flag);
			}
			else
			{
				throw new ArgumentNullException("siteName");
			}
		}
        internal static GlobalCatalog FindOneInternal(DirectoryContext context, string forestName, string siteName, LocatorOptions flag)
        {
            DomainControllerInfo info;
            int errorCode = 0;

            if ((siteName != null) && (siteName.Length == 0))
            {
                throw new ArgumentException(Res.GetString("EmptyStringParameter"), "siteName");
            }
            if ((flag & ~(LocatorOptions.AvoidSelf | LocatorOptions.ForceRediscovery | LocatorOptions.KdcRequired | LocatorOptions.TimeServerRequired | LocatorOptions.WriteableRequired)) != 0L)
            {
                throw new ArgumentException(Res.GetString("InvalidFlags"), "flag");
            }
            if (forestName == null)
            {
                DomainControllerInfo info2;
                int num2 = Locator.DsGetDcNameWrapper(null, DirectoryContext.GetLoggedOnDomain(), null, 0x10L, out info2);
                if (num2 == 0x54b)
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString("ContextNotAssociatedWithDomain"), typeof(GlobalCatalog), null);
                }
                if (num2 != 0)
                {
                    throw ExceptionHelper.GetExceptionFromErrorCode(errorCode);
                }
                forestName = info2.DnsForestName;
            }
            errorCode = Locator.DsGetDcNameWrapper(null, forestName, siteName, flag | 80L, out info);
            switch (errorCode)
            {
            case 0x54b:
                throw new ActiveDirectoryObjectNotFoundException(Res.GetString("GCNotFoundInForest", new object[] { forestName }), typeof(GlobalCatalog), null);

            case 0x3ec:
                throw new ArgumentException(Res.GetString("InvalidFlags"), "flag");
            }
            if (errorCode != 0)
            {
                throw ExceptionHelper.GetExceptionFromErrorCode(errorCode);
            }
            string globalCatalogName = info.DomainControllerName.Substring(2);

            return(new GlobalCatalog(Utils.GetNewDirectoryContext(globalCatalogName, DirectoryContextType.DirectoryServer, context), globalCatalogName));
        }
Esempio n. 31
0
 public DomainController FindDomainController(LocatorOptions flag)
 {
 }
Esempio n. 32
0
        public static System.DirectoryServices.ActiveDirectory.DomainController FindOne(DirectoryContext context, LocatorOptions flag)
        {
            Contract.Requires(context != null);
            Contract.Requires(context.ContextType == DirectoryContextType.Domain);

            return(default(System.DirectoryServices.ActiveDirectory.DomainController));
        }
 public GlobalCatalog FindGlobalCatalog(LocatorOptions flag)
 {
 }
        internal static DomainController FindOneInternal(DirectoryContext context, string domainName, string siteName, LocatorOptions flag)
        {
            DomainControllerInfo info;
            int errorCode = 0;

            if ((siteName != null) && (siteName.Length == 0))
            {
                throw new ArgumentException(Res.GetString("EmptyStringParameter"), "siteName");
            }
            if ((flag & ~(LocatorOptions.AvoidSelf | LocatorOptions.ForceRediscovery | LocatorOptions.KdcRequired | LocatorOptions.TimeServerRequired | LocatorOptions.WriteableRequired)) != 0L)
            {
                throw new ArgumentException(Res.GetString("InvalidFlags"), "flag");
            }
            if (domainName == null)
            {
                domainName = DirectoryContext.GetLoggedOnDomain();
            }
            errorCode = Locator.DsGetDcNameWrapper(null, domainName, siteName, flag | 0x10L, out info);
            switch (errorCode)
            {
            case 0x54b:
                throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DCNotFoundInDomain", new object[] { domainName }), typeof(DomainController), null);

            case 0x3ec:
                throw new ArgumentException(Res.GetString("InvalidFlags"), "flag");
            }
            if (errorCode != 0)
            {
                throw System.DirectoryServices.ActiveDirectory.ExceptionHelper.GetExceptionFromErrorCode(errorCode);
            }
            string domainControllerName = info.DomainControllerName.Substring(2);

            return(new DomainController(Utils.GetNewDirectoryContext(domainControllerName, DirectoryContextType.DirectoryServer, context), domainControllerName));
        }
	public DomainController FindDomainController(string siteName, LocatorOptions flag) {}
        internal static DomainController FindOneWithCredentialValidation(DirectoryContext context, string siteName, LocatorOptions flag)
        {
            bool flag2 = false;
            bool flag3 = false;

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

            try
            {
                ValidateCredential(dc, context);
                flag3 = true;
            }
            catch (COMException exception)
            {
                if (exception.ErrorCode != -2147016646)
                {
                    throw System.DirectoryServices.ActiveDirectory.ExceptionHelper.GetExceptionFromCOMException(context, exception);
                }
                if ((flag & LocatorOptions.ForceRediscovery) != 0L)
                {
                    throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DCNotFoundInDomain", new object[] { context.Name }), typeof(DomainController), null);
                }
                flag2 = true;
            }
            finally
            {
                if (!flag3)
                {
                    dc.Dispose();
                }
            }
            if (flag2)
            {
                flag3 = false;
                dc    = FindOneInternal(context, context.Name, siteName, flag | LocatorOptions.ForceRediscovery);
                try
                {
                    ValidateCredential(dc, context);
                    flag3 = true;
                }
                catch (COMException exception2)
                {
                    if (exception2.ErrorCode == -2147016646)
                    {
                        throw new ActiveDirectoryObjectNotFoundException(Res.GetString("DCNotFoundInDomain", new object[] { context.Name }), typeof(DomainController), null);
                    }
                    throw System.DirectoryServices.ActiveDirectory.ExceptionHelper.GetExceptionFromCOMException(context, exception2);
                }
                finally
                {
                    if (!flag3)
                    {
                        dc.Dispose();
                    }
                }
            }
            return(dc);
        }
Esempio n. 37
0
        public GlobalCatalog FindGlobalCatalog(LocatorOptions flag)
        {
            CheckIfDisposed();

            return(GlobalCatalog.FindOneInternal(_context, Name, null, flag));
        }
	public static DomainController FindOne(DirectoryContext context, string siteName, LocatorOptions flag) {}
Esempio n. 39
0
		public DomainController FindDomainController(LocatorOptions flag)
		{
			base.CheckIfDisposed();
			return DomainController.FindOneInternal(this.context, base.Name, null, flag);
		}
        public DomainController FindDomainController(string siteName, LocatorOptions flag)
        {
            Contract.Ensures(Contract.Result <DomainController>() != null);

            return(default(DomainController));
        }
Esempio n. 41
0
        internal static DomainController FindOneWithCredentialValidation(DirectoryContext context, string siteName, LocatorOptions flag)
        {
            DomainController dc;
            bool retry = false;
            bool credsValidated = false;

            //  work with copy of the context
            context = new DirectoryContext(context);

            // authenticate against this DC to validate the credentials
            dc = FindOneInternal(context, context.Name, siteName, flag);
            try
            {
                ValidateCredential(dc, context);
                credsValidated = true;
            }
            catch (COMException e)
            {
                if (e.ErrorCode == unchecked((int)0x8007203a))
                {
                    // server is down , so try again with force rediscovery if the flags did not already contain force rediscovery
                    if ((flag & LocatorOptions.ForceRediscovery) == 0)
                    {
                        retry = true;
                    }
                    else
                    {
                        throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DCNotFoundInDomain, context.Name), typeof(DomainController), null);
                    }
                }
                else
                {
                    throw ExceptionHelper.GetExceptionFromCOMException(context, e);
                }
            }
            finally
            {
                if (!credsValidated)
                {
                    dc.Dispose();
                }
            }

            if (retry)
            {
                credsValidated = false;
                dc = FindOneInternal(context, context.Name, siteName, flag | LocatorOptions.ForceRediscovery);
                try
                {
                    ValidateCredential(dc, context);
                    credsValidated = true;
                }
                catch (COMException e)
                {
                    if (e.ErrorCode == unchecked((int)0x8007203a))
                    {
                        // server is down
                        throw new ActiveDirectoryObjectNotFoundException(Res.GetString(Res.DCNotFoundInDomain, context.Name), typeof(DomainController), null);
                    }
                    else
                    {
                        throw ExceptionHelper.GetExceptionFromCOMException(context, e);
                    }
                }
                finally
                {
                    if (!credsValidated)
                    {
                        dc.Dispose();
                    }
                }
            }

            return dc;
        }
Esempio n. 42
0
 public static DomainController FindOne(DirectoryContext context, string siteName, LocatorOptions flag)
 {
 }
Esempio n. 43
0
        public static DomainController FindOne(DirectoryContext context, string siteName, LocatorOptions flag)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            if (context.ContextType != DirectoryContextType.Domain)
            {
                throw new ArgumentException(Res.GetString(Res.TargetShouldBeDomain), "context");
            }

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

            return FindOneWithCredentialValidation(context, siteName, flag);
        }
Esempio n. 44
0
 public GlobalCatalog FindGlobalCatalog(LocatorOptions flag)
 {
     throw new NotImplementedException();
 }
	public GlobalCatalog FindGlobalCatalog(string siteName, LocatorOptions flag) {}
Esempio n. 46
0
 public GlobalCatalog FindGlobalCatalog(string siteName, LocatorOptions flag)
 {
     throw new NotImplementedException();
 }
Esempio n. 47
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");
			}
		}
Esempio n. 48
0
 public DomainController FindDomainController(string siteName, LocatorOptions flag)
 {
     throw new NotImplementedException();
 }
Esempio n. 49
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;
		}
    public static System.DirectoryServices.ActiveDirectory.DomainController FindOne(DirectoryContext context, string siteName, LocatorOptions flag)
    {
      Contract.Requires(context != null);
      Contract.Requires(context.ContextType == DirectoryContextType.Domain);
      Contract.Requires(siteName != null);

      return default(System.DirectoryServices.ActiveDirectory.DomainController);
    }
Esempio n. 51
0
        internal static new GlobalCatalog FindOneWithCredentialValidation(DirectoryContext context, string?siteName, LocatorOptions flag)
        {
            GlobalCatalog gc;
            bool          retry          = false;
            bool          credsValidated = false;

            //  work with copy of the context
            context = new DirectoryContext(context);

            // authenticate against this GC to validate the credentials
            gc = FindOneInternal(context, context.Name, siteName, flag);
            try
            {
                ValidateCredential(gc, context);
                credsValidated = true;
            }
            catch (COMException e)
            {
                if (e.ErrorCode == unchecked ((int)0x8007203a))
                {
                    // server is down , so try again with force rediscovery if the flags did not already contain force rediscovery
                    if ((flag & LocatorOptions.ForceRediscovery) == 0)
                    {
                        retry = true;
                    }
                    else
                    {
                        throw new ActiveDirectoryObjectNotFoundException(SR.Format(SR.GCNotFoundInForest, context.Name), typeof(GlobalCatalog), null);
                    }
                }
                else
                {
                    throw ExceptionHelper.GetExceptionFromCOMException(context, e);
                }
            }
            finally
            {
                if (!credsValidated)
                {
                    gc.Dispose();
                }
            }

            if (retry)
            {
                credsValidated = false;
                gc             = FindOneInternal(context, context.Name, siteName, flag | LocatorOptions.ForceRediscovery);
                try
                {
                    ValidateCredential(gc, context);
                    credsValidated = true;
                }
                catch (COMException e)
                {
                    if (e.ErrorCode == unchecked ((int)0x8007203a))
                    {
                        // server is down
                        throw new ActiveDirectoryObjectNotFoundException(SR.Format(SR.GCNotFoundInForest, context.Name), typeof(GlobalCatalog), null);
                    }
                    else
                    {
                        throw ExceptionHelper.GetExceptionFromCOMException(context, e);
                    }
                }
                finally
                {
                    if (!credsValidated)
                    {
                        gc.Dispose();
                    }
                }
            }

            return(gc);
        }
Esempio n. 52
0
        public DomainController FindDomainController(string siteName, LocatorOptions flag)
        {
            CheckIfDisposed();

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

            return DomainController.FindOneInternal(context, Name, siteName, flag);
        }
Esempio n. 53
0
		public GlobalCatalog FindGlobalCatalog (LocatorOptions flag)
		{
			throw new NotImplementedException ();
		}
	public static GlobalCatalog FindOne(DirectoryContext context, string siteName, LocatorOptions flag) {}
Esempio n. 55
0
		public GlobalCatalog FindGlobalCatalog(LocatorOptions flag)
		{
			this.CheckIfDisposed();
			return GlobalCatalog.FindOneInternal(this.context, this.Name, null, flag);
		}
 public GlobalCatalog FindGlobalCatalog(string siteName, LocatorOptions flag)
 {
   Contract.Requires(siteName != null);
   Contract.Ensures(Contract.Result<GlobalCatalog>() != null);
   
   return default(GlobalCatalog);
 }
    public GlobalCatalog FindGlobalCatalog(LocatorOptions flag)
    {
      Contract.Ensures(Contract.Result<GlobalCatalog>() != null);

      return default(GlobalCatalog);
    }
Esempio n. 58
0
		public static DomainController FindOne(DirectoryContext context, LocatorOptions flag)
		{
			if (context != null)
			{
				if (context.ContextType == DirectoryContextType.Domain)
				{
					return DomainController.FindOneWithCredentialValidation(context, null, flag);
				}
				else
				{
					throw new ArgumentException(Res.GetString("TargetShouldBeDomain"), "context");
				}
			}
			else
			{
				throw new ArgumentNullException("context");
			}
		}