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);
        }
예제 #2
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);
        }