Exemplo n.º 1
0
        internal override ADObject GetDirectoryObjectFromIdentity(T identityObj, string searchRoot, bool showDeleted)
        {
            ADObject aDSessionInfo;

            this.ValidateIdentity(identityObj);
            string           str = string.Concat("CN=Partitions,", base.CmdletSessionInfo.ADRootDSE.ConfigurationNamingContext);
            ADObjectSearcher structuralObjectFilter = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, str, ADSearchScope.Base);

            using (structuralObjectFilter)
            {
                AttributeSetRequest attributeSetRequest = this.ConstructAttributeSetRequest(null);
                structuralObjectFilter.Properties.AddRange(attributeSetRequest.DirectoryAttributes);
                structuralObjectFilter.Filter = this.StructuralObjectFilter;
                DebugLogger.LogInfo("ADForestFactory", string.Format("GetDirectoryObjectFromIdentity: Searching for identity using filter: {0} searchbase: {1}", structuralObjectFilter.Filter.GetLdapFilterString(), structuralObjectFilter.SearchRoot));
                aDSessionInfo = structuralObjectFilter.FindOne();
                if (aDSessionInfo == null)
                {
                    DebugLogger.LogInfo("ADForestFactory", string.Format("GetDirectoryObjectFromIdentity: Identity not found.", new object[0]));
                    object[] objArray = new object[2];
                    objArray[0] = identityObj.ToString();
                    objArray[1] = structuralObjectFilter.SearchRoot;
                    throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, objArray));
                }
            }
            aDSessionInfo.TrackChanges = true;
            aDSessionInfo.SessionInfo  = base.CmdletSessionInfo.ADSessionInfo;
            return(aDSessionInfo);
        }
Exemplo n.º 2
0
        public static string FindDomainNCHead(string identity, CmdletSessionInfo session)
        {
            ADObject aDObject;

            using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(session.ADSessionInfo))
            {
                aDObjectSearcher.SearchRoot = string.Concat("CN=Partitions,", session.ADRootDSE.ConfigurationNamingContext);
                aDObjectSearcher.Scope      = ADSearchScope.OneLevel;
                IADOPathNode[] aDOPathNodeArray = new IADOPathNode[3];
                aDOPathNodeArray[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectCategory", "crossRef");
                aDOPathNodeArray[1] = ADOPathUtil.CreateFilterClause(ADOperator.Band, "systemFlags", 3);
                IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[3];
                aDOPathNodeArray1[0]    = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "nCName", identity);
                aDOPathNodeArray1[1]    = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "nETBIOSName", identity);
                aDOPathNodeArray1[2]    = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "dnsRoot", identity);
                aDOPathNodeArray[2]     = ADOPathUtil.CreateOrClause(aDOPathNodeArray1);
                aDObjectSearcher.Filter = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
                aDObjectSearcher.Properties.Add("nCName");
                aDObject = aDObjectSearcher.FindOne();
            }
            if (aDObject != null)
            {
                return(aDObject.GetValue("nCName") as string);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        private void ValidateIdentity(T identityObj)
        {
            string str;

            if (identityObj != null)
            {
                if (base.CmdletSessionInfo != null)
                {
                    if (!identityObj.IsSearchResult)
                    {
                        if (identityObj.Identity as ADDomain == null || !((ADDomain)identityObj.Identity).IsSearchResult)
                        {
                            str = identityObj.Identity.ToString();
                        }
                        else
                        {
                            str = ((ADDomain)identityObj.Identity).DNSRoot;
                        }
                    }
                    else
                    {
                        str = identityObj.Name;
                    }
                    ADRootDSE        aDRootDSE        = base.CmdletSessionInfo.ADRootDSE;
                    string           str1             = string.Concat("CN=Partitions,", aDRootDSE.ConfigurationNamingContext);
                    ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, str1, ADSearchScope.OneLevel);
                    using (aDObjectSearcher)
                    {
                        IADOPathNode[] aDOPathNodeArray = new IADOPathNode[3];
                        aDOPathNodeArray[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "crossRef");
                        IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[2];
                        aDOPathNodeArray1[0]    = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "dnsRoot", str);
                        aDOPathNodeArray1[1]    = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "nETBIOSName", str);
                        aDOPathNodeArray[1]     = ADOPathUtil.CreateOrClause(aDOPathNodeArray1);
                        aDOPathNodeArray[2]     = ADOPathUtil.CreateFilterClause(ADOperator.Band, "systemFlags", 3);
                        aDObjectSearcher.Filter = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
                        ADObject aDObject = aDObjectSearcher.FindOne();
                        if (aDObject == null)
                        {
                            object[] objArray = new object[1];
                            objArray[0] = str;
                            throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.CouldNotFindForestIdentity, objArray));
                        }
                    }
                    return;
                }
                else
                {
                    throw new ArgumentNullException(StringResources.SessionRequired);
                }
            }
            else
            {
                object[] type = new object[2];
                type[0] = "ValidateIdentity";
                type[1] = identityObj.GetType();
                throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.MethodNotSupportedForObjectType, type));
            }
        }
Exemplo n.º 4
0
        private double GetInactiveTimeSpanDays(CmdletSessionInfo cmdletSessionInfo)
        {
            double    num = 0;
            double    num1;
            ADRootDSE rootDSE = this.GetRootDSE();
            string    defaultNamingContext = rootDSE.DefaultNamingContext;

            if (rootDSE.ServerType != ADServerType.ADDS || defaultNamingContext == null)
            {
                return(15);
            }
            else
            {
                SearchADAccountCmdlet._accountInactiveTimeSpanLock.EnterReadLock();
                try
                {
                    if (!SearchADAccountCmdlet._accountInactiveTimeSpanCache.TryGetValue(defaultNamingContext, out num))
                    {
                        double           value            = 15;
                        ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, defaultNamingContext, ADSearchScope.Base);
                        using (aDObjectSearcher)
                        {
                            aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
                            aDObjectSearcher.Properties.Add("msDS-LogonTimeSyncInterval");
                            ADObject aDObject = aDObjectSearcher.FindOne();
                            if (aDObject != null && aDObject.Contains("msDS-LogonTimeSyncInterval") && aDObject["msDS-LogonTimeSyncInterval"].Count > 0)
                            {
                                value = (double)((int)aDObject["msDS-LogonTimeSyncInterval"].Value);
                            }
                        }
                        SearchADAccountCmdlet._accountInactiveTimeSpanLock.EnterWriteLock();
                        try
                        {
                            SearchADAccountCmdlet._accountInactiveTimeSpanCache[defaultNamingContext] = value;
                        }
                        finally
                        {
                            SearchADAccountCmdlet._accountInactiveTimeSpanLock.ExitWriteLock();
                        }
                        return(value);
                    }
                    else
                    {
                        num1 = num;
                    }
                }
                finally
                {
                    SearchADAccountCmdlet._accountInactiveTimeSpanLock.ExitReadLock();
                }
                return(num1);
            }
        }
        internal override ADObject GetDirectoryObjectFromIdentity(T identityObj, string searchRoot, bool showDeleted)
        {
            ADObject aDObject  = null;
            ADObject aDObject1 = null;
            ADObject aDObject2 = null;
            ADObject aDSessionInfo;

            if (base.CmdletSessionInfo != null)
            {
                //base.CmdletSessionInfo.ADRootDSE.ConfigurationNamingContext;
                string nTDSSettingsDN = this.ResolveIdentityToNTDSSettingsDN(identityObj, ADDirectoryServerFactory <T> ._directoryServerDefaultAttributes, false, out aDObject, out aDObject1, out aDObject2);
                if (nTDSSettingsDN != null)
                {
                    if (aDObject1 == null)
                    {
                        string           str = nTDSSettingsDN.Substring("CN=NTDS Settings,".Length);
                        ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, str, ADSearchScope.Base);
                        using (aDObjectSearcher)
                        {
                            aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
                            aDObjectSearcher.Properties.AddRange(ADDirectoryServerFactory <T> ._directoryServerDefaultAttributes);
                            aDSessionInfo = aDObjectSearcher.FindOne();
                            if (aDSessionInfo == null)
                            {
                                DebugLogger.LogInfo("ADDirectoryServerFactory", string.Format("GetDirectoryObjectFromIdentity: Identity not found.", new object[0]));
                                object[] objArray = new object[2];
                                objArray[0] = identityObj.ToString();
                                objArray[1] = str;
                                throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, objArray));
                            }
                        }
                    }
                    else
                    {
                        aDSessionInfo = aDObject1;
                    }
                    aDSessionInfo.TrackChanges = true;
                    aDSessionInfo.SessionInfo  = base.CmdletSessionInfo.ADSessionInfo;
                    return(aDSessionInfo);
                }
                else
                {
                    DebugLogger.LogInfo("ADDirectoryServerFactory", string.Format("GetDirectoryObjectFromIdentity: NTDS Settings DN for the given identity not found", new object[0]));
                    object[] identity = new object[1];
                    identity[0] = identityObj.Identity;
                    throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.DirectoryServerNotFound, identity));
                }
            }
            else
            {
                throw new ArgumentNullException(StringResources.SessionRequired);
            }
        }
Exemplo n.º 6
0
        private static int GetNTMixedDomainMode(CmdletSessionInfo cmdletSessionInfo)
        {
            int value;
            ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, cmdletSessionInfo.ADRootDSE.DefaultNamingContext, ADSearchScope.Base);

            using (aDObjectSearcher)
            {
                aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
                aDObjectSearcher.Properties.Add("ntMixedDomain");
                ADObject aDObject = aDObjectSearcher.FindOne();
                value = (int)aDObject["ntMixedDomain"].Value;
            }
            return(value);
        }
Exemplo n.º 7
0
        internal override T GetExtendedObjectFromIdentity(T identityObj, string identityQueryPath, ICollection <string> propertiesToFetch, bool showDeleted)
        {
            ADObject aDObject;
            ADDefaultDomainPasswordPolicy aDDefaultDomainPasswordPolicy = identityObj;

            if (aDDefaultDomainPasswordPolicy != null)
            {
                if (base.CmdletSessionInfo != null)
                {
                    AttributeSetRequest attributeSetRequest    = this.ConstructAttributeSetRequest(propertiesToFetch);
                    IADOPathNode[]      structuralObjectFilter = new IADOPathNode[2];
                    structuralObjectFilter[0] = this.StructuralObjectFilter;
                    structuralObjectFilter[1] = this.BuildIdentityFilter(identityObj);
                    IADOPathNode     aDOPathNode          = ADOPathUtil.CreateAndClause(structuralObjectFilter);
                    string           defaultNamingContext = base.CmdletSessionInfo.ADRootDSE.DefaultNamingContext;
                    ADSearchScope    aDSearchScope        = ADSearchScope.Base;
                    ADObjectSearcher aDObjectSearcher     = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, defaultNamingContext, aDSearchScope, showDeleted);
                    using (aDObjectSearcher)
                    {
                        aDObjectSearcher.Filter = aDOPathNode;
                        aDObjectSearcher.Properties.AddRange(attributeSetRequest.DirectoryAttributes);
                        DebugLogger.LogInfo("ADDefaultDomainPasswordPolicyFactory", string.Format("ADFactory: GetExtendedObjectFromIdentity: Searching for identity using filter: {0} searchbase: {1} scope: {2}", aDObjectSearcher.Filter.GetLdapFilterString(), aDObjectSearcher.SearchRoot, aDObjectSearcher.Scope));
                        aDObject = aDObjectSearcher.FindOne();
                        if (aDObject == null)
                        {
                            DebugLogger.LogInfo("ADDefaultDomainPasswordPolicyFactory", string.Format("ADFactory: GetExtendedObjectFromIdentity: Identity not found", new object[0]));
                            object[] str = new object[2];
                            str[0] = identityObj.ToString();
                            str[1] = aDObjectSearcher.SearchRoot;
                            throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, str));
                        }
                    }
                    T aDSessionInfo = this.Construct(aDObject, attributeSetRequest);
                    aDSessionInfo.SessionInfo = base.CmdletSessionInfo.ADSessionInfo;
                    return(aDSessionInfo);
                }
                else
                {
                    throw new ArgumentNullException(StringResources.SessionRequired);
                }
            }
            else
            {
                object[] type = new object[2];
                type[0] = "GetExtendedObjectFromIdentity";
                type[1] = identityObj.GetType();
                throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.MethodNotSupportedForObjectType, type));
            }
        }
Exemplo n.º 8
0
        internal static ADObject GetDirectoryObject(string DN, string[] directoryAttributes, CmdletSessionInfo cmdletSessionInfo)
        {
            ADObject aDObject;

            using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(cmdletSessionInfo.ADSessionInfo))
            {
                aDObjectSearcher.SearchRoot = DN;
                aDObjectSearcher.Scope      = ADSearchScope.Base;
                if (directoryAttributes != null)
                {
                    aDObjectSearcher.Properties.AddRange(directoryAttributes);
                }
                aDObject = aDObjectSearcher.FindOne();
            }
            return(aDObject);
        }
Exemplo n.º 9
0
        internal override ADObject GetDirectoryObjectFromIdentity(T identityObj, string searchRoot, bool showDeleted)
        {
            ADObject aDSessionInfo;

            if (base.CmdletSessionInfo != null)
            {
                string           defaultNamingContext = base.CmdletSessionInfo.ADRootDSE.DefaultNamingContext;
                ADObjectSearcher aDObjectSearcher     = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, defaultNamingContext, ADSearchScope.Base);
                using (aDObjectSearcher)
                {
                    AttributeSetRequest attributeSetRequest = this.ConstructAttributeSetRequest(null);
                    aDObjectSearcher.Properties.AddRange(attributeSetRequest.DirectoryAttributes);
                    IADOPathNode[] structuralObjectFilter = new IADOPathNode[2];
                    structuralObjectFilter[0] = this.StructuralObjectFilter;
                    structuralObjectFilter[1] = this.BuildIdentityFilter(identityObj);
                    aDObjectSearcher.Filter   = ADOPathUtil.CreateAndClause(structuralObjectFilter);
                    DebugLogger.LogInfo("ADDefaultDomainPasswordPolicyFactory", string.Format("GetDirectoryObjectFromIdentity: Searching for identity using filter: {0} searchbase: {1}", aDObjectSearcher.Filter.GetLdapFilterString(), aDObjectSearcher.SearchRoot));
                    aDSessionInfo = aDObjectSearcher.FindOne();
                    if (aDSessionInfo == null)
                    {
                        DebugLogger.LogInfo("ADDefaultDomainPasswordPolicyFactory", string.Format("GetDirectoryObjectFromIdentity: Identity not found.", new object[0]));
                        object[] str = new object[2];
                        str[0] = identityObj.ToString();
                        str[1] = aDObjectSearcher.SearchRoot;
                        throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, str));
                    }
                }
                if (!aDSessionInfo.ObjectClass.Equals("domainDNS", StringComparison.OrdinalIgnoreCase))
                {
                    object[] objArray = new object[2];
                    objArray[0] = identityObj.ToString();
                    objArray[1] = defaultNamingContext;
                    throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, objArray));
                }
                else
                {
                    aDSessionInfo.TrackChanges = true;
                    aDSessionInfo.SessionInfo  = base.CmdletSessionInfo.ADSessionInfo;
                    return(aDSessionInfo);
                }
            }
            else
            {
                throw new ArgumentNullException(StringResources.SessionRequired);
            }
        }
Exemplo n.º 10
0
        internal static ADObject GetObjectFromIdentitySearcher(ADObjectSearcher searcher, ADEntity identityObj, string searchRoot, AttributeSetRequest attrs, CmdletSessionInfo cmdletSessionInfo, out string[] warningMessages)
        {
            ADObject aDObject;
            bool     flag = false;

            warningMessages = new string[0];
            using (searcher)
            {
                searcher.Properties.AddRange(attrs.DirectoryAttributes);
                DebugLogger.LogInfo("ADFactoryUtil", string.Format("GetObjectFromIdentity: Searching for identity using filter: {0} searchbase: {1}", searcher.Filter.GetLdapFilterString(), searcher.SearchRoot));
                aDObject = searcher.FindOne(out flag);
                if (aDObject != null)
                {
                    if (flag)
                    {
                        throw new ADMultipleMatchingIdentitiesException(StringResources.MultipleMatches);
                    }
                }
                else
                {
                    DebugLogger.LogInfo("ADFactoryUtil", string.Format("GetObjectFromIdentity: Identity not found.", new object[0]));
                    object[] str = new object[2];
                    str[0] = identityObj.ToString();
                    str[1] = searchRoot;
                    throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, str));
                }
            }
            string str1 = ADForestPartitionInfo.ExtractPartitionInfo(cmdletSessionInfo.ADRootDSE, aDObject.DistinguishedName, false);

            if (cmdletSessionInfo.CmdletParameters.Contains("Partition"))
            {
                string item = cmdletSessionInfo.CmdletParameters["Partition"] as string;
                if (!ADPathModule.ComparePath(item, str1, ADPathFormat.X500))
                {
                    string[] strArrays = new string[1];
                    object[] objArray  = new object[3];
                    objArray[0]     = identityObj.ToString();
                    objArray[1]     = str1;
                    objArray[2]     = item;
                    strArrays[0]    = string.Format(CultureInfo.CurrentCulture, StringResources.IdentityInWrongPartition, objArray);
                    warningMessages = strArrays;
                }
            }
            cmdletSessionInfo.DefaultPartitionPath = str1;
            return(aDObject);
        }
Exemplo n.º 11
0
        private bool MoveADDirectoryServerProcessCSRoutine()
        {
            this._identityDSObj = this._cmdletParameters["Identity"] as ADDirectoryServer;
            base.SetPipelinedSessionInfo(this._identityDSObj.SessionInfo);
            CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo();
            ADDirectoryServerFactory <ADDirectoryServer> aDDirectoryServerFactory = new ADDirectoryServerFactory <ADDirectoryServer>();

            aDDirectoryServerFactory.SetCmdletSessionInfo(cmdletSessionInfo);
            ADObject         directoryObjectFromIdentity = aDDirectoryServerFactory.GetDirectoryObjectFromIdentity(this._identityDSObj, cmdletSessionInfo.DefaultPartitionPath);
            string           str = string.Concat("CN=Servers,", this._siteDirObj.DistinguishedName);
            ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, str, ADSearchScope.Base);

            using (aDObjectSearcher)
            {
                aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
                ADObject aDObject = aDObjectSearcher.FindOne();
                if (aDObject == null)
                {
                    base.ThrowTerminatingError(ADUtilities.GetErrorRecord(new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.ObjectNotFound, new object[0])), "MoveADDirectoryServer:ProcessRecord", str));
                }
                StringBuilder stringBuilder = new StringBuilder("Move-ADObject -identity $args[0]  -Partition $args[1]  -TargetPath $args[2] ");
                try
                {
                    object[] configurationNamingContext = new object[3];
                    configurationNamingContext[0] = directoryObjectFromIdentity;
                    configurationNamingContext[1] = cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext;
                    configurationNamingContext[2] = aDObject.DistinguishedName;
                    base.InvokeCommand.InvokeScript(stringBuilder.ToString(), false, PipelineResultTypes.Output, null, configurationNamingContext);
                }
                catch (RuntimeException runtimeException1)
                {
                    RuntimeException runtimeException  = runtimeException1;
                    object[]         distinguishedName = new object[3];
                    distinguishedName[0] = directoryObjectFromIdentity.DistinguishedName;
                    distinguishedName[1] = this._siteDirObj.DistinguishedName;
                    distinguishedName[2] = runtimeException.Message;
                    string str1 = string.Format(CultureInfo.CurrentCulture, "Failed moving the directory server: {0} to new site: {1}. Error:  {2}", distinguishedName);
                    DebugLogger.LogError("MoveADDirectoryServer", str1);
                    base.WriteError(new ErrorRecord(runtimeException, "0", ErrorCategory.WriteError, this._identityDSObj));
                }
            }
            return(true);
        }
Exemplo n.º 12
0
        internal static string GetWellKnownGuidDN(ADSessionInfo adSession, string partitionDN, string wellKnownGuid)
        {
            string distinguishedName;

            if (partitionDN != null)
            {
                ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(adSession);
                try
                {
                    try
                    {
                        aDObjectSearcher.SearchRoot = string.Format("<WKGUID={0},{1}>", wellKnownGuid, partitionDN);
                        aDObjectSearcher.Scope      = ADSearchScope.Base;
                        aDObjectSearcher.Filter     = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
                        ADObject aDObject = aDObjectSearcher.FindOne();
                        if (aDObject == null)
                        {
                            distinguishedName = null;
                        }
                        else
                        {
                            distinguishedName = aDObject.DistinguishedName;
                        }
                    }
                    catch (ADIdentityNotFoundException aDIdentityNotFoundException1)
                    {
                        ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1;
                        DebugLogger.LogError("Utils", string.Format("Error in searching for WKGUID {0}", aDIdentityNotFoundException.Message));
                        distinguishedName = null;
                    }
                }
                finally
                {
                    aDObjectSearcher.Dispose();
                }
                return(distinguishedName);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 13
0
        internal static bool IsStaleServerObject(ADSessionInfo sessionInfo, string serverObjectDN)
        {
            bool flag;

            if (serverObjectDN != null)
            {
                ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(sessionInfo, serverObjectDN, ADSearchScope.OneLevel);
                using (aDObjectSearcher)
                {
                    aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "nTDSDSA");
                    ADObject aDObject = aDObjectSearcher.FindOne();
                    flag = aDObject == null;
                }
                return(flag);
            }
            else
            {
                throw new ArgumentNullException("serverObjectDN");
            }
        }
Exemplo n.º 14
0
        private bool GetADAcctResPrpProcessCSRoutine()
        {
            ADResultantPasswordReplicationPolicy aDResultantPasswordReplicationPolicy = ADResultantPasswordReplicationPolicy.DenyExplicit;
            int?value;

            this._partitionPath     = this._cmdletParameters["Partition"] as string;
            this._identityADAccount = this._cmdletParameters["Identity"] as ADAccount;
            this._targetDCAccount   = this._cmdletParameters["DomainController"] as ADDomainController;
            base.SetPipelinedSessionInfo(this._identityADAccount.SessionInfo);
            CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo();

            if (cmdletSessionInfo.ADRootDSE.IsWindows2008AndAbove())
            {
                if (!cmdletSessionInfo.ADRootDSE.IsWritable())
                {
                    object[] dNSHostName = new object[1];
                    dNSHostName[0] = cmdletSessionInfo.ADRootDSE.DNSHostName;
                    base.WriteWarning(string.Format(CultureInfo.CurrentCulture, StringResources.WarningResultantPRPNotAccurateOnRODC, dNSHostName));
                }
                ADDomainControllerFactory <ADDomainController> aDDomainControllerFactory = new ADDomainControllerFactory <ADDomainController>();
                aDDomainControllerFactory.SetCmdletSessionInfo(cmdletSessionInfo);
                ADAccountFactory <ADAccount> aDAccountFactory = new ADAccountFactory <ADAccount>();
                aDAccountFactory.SetCmdletSessionInfo(cmdletSessionInfo);
                ADObject         directoryObjectFromIdentity = aDDomainControllerFactory.GetDirectoryObjectFromIdentity(this._targetDCAccount, cmdletSessionInfo.DefaultPartitionPath);
                ADObject         aDObject          = aDAccountFactory.GetDirectoryObjectFromIdentity(this._identityADAccount, cmdletSessionInfo.DefaultPartitionPath);
                ADObjectSearcher distinguishedName = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, directoryObjectFromIdentity.DistinguishedName, ADSearchScope.Base);
                using (distinguishedName)
                {
                    distinguishedName.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
                    distinguishedName.Properties.Add("msDS-IsUserCachableAtRodc");
                    distinguishedName.InputDN = aDObject.DistinguishedName;
                    ADObject aDObject1 = distinguishedName.FindOne();
                    if (aDObject1["msDS-IsUserCachableAtRodc"] == null)
                    {
                        int?nullable = null;
                        value = nullable;
                    }
                    else
                    {
                        value = (int?)aDObject1["msDS-IsUserCachableAtRodc"].Value;
                    }
                    int?nullable1 = value;
                    if (nullable1.HasValue)
                    {
                        if (!Utils.TryParseEnum <ADResultantPasswordReplicationPolicy>(nullable1.ToString(), out aDResultantPasswordReplicationPolicy))
                        {
                            DebugLogger.LogInfo("GetADAccountResultantPasswordReplicationPolicy", string.Format("Error parsing resultant prp: {0} for account {1} on RODC {2}", aDResultantPasswordReplicationPolicy, aDObject.DistinguishedName, directoryObjectFromIdentity.DistinguishedName));
                            base.WriteObject(ADResultantPasswordReplicationPolicy.Unknown);
                        }
                        else
                        {
                            base.WriteObject(aDResultantPasswordReplicationPolicy);
                        }
                    }
                    else
                    {
                        base.WriteObject(ADResultantPasswordReplicationPolicy.Unknown);
                    }
                }
                return(true);
            }
            else
            {
                base.WriteError(new ErrorRecord(new ArgumentException(StringResources.ErrorResultantPRPSpecifyWindows2008OrAbove), "GetADAccountResultantPasswordReplicationPolicy:ProcessRecord", ErrorCategory.InvalidData, null));
                return(false);
            }
        }
Exemplo n.º 15
0
        internal ADObject GetDirectoryObjectFromIdentity(T identityObj, string searchRoot, ICollection <string> propertiesToFetch)
        {
            ADObject         aDObject  = null;
            ADObject         aDObject1 = null;
            ADObject         aDObject2 = null;
            HashSet <string> strs      = new HashSet <string>(ADDomainControllerFactory <T> ._domainControllerDefaultAttributes, StringComparer.OrdinalIgnoreCase);

            if (propertiesToFetch != null)
            {
                strs.UnionWith(propertiesToFetch);
            }
            string[] strArrays = new string[strs.Count];
            strs.CopyTo(strArrays);
            string nTDSSettingsDN = base.ResolveIdentityToNTDSSettingsDN(identityObj, strArrays, true, out aDObject, out aDObject1, out aDObject2);

            if (nTDSSettingsDN != null)
            {
                ADObject aDSessionInfo = null;
                if (aDObject == null)
                {
                    string value = null;
                    if (aDObject1 == null)
                    {
                        string           str = nTDSSettingsDN.Substring("CN=NTDS Settings,".Length);
                        ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, str, ADSearchScope.Base);
                        using (aDObjectSearcher)
                        {
                            aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
                            string[] strArrays1 = new string[1];
                            strArrays1[0] = "serverReference";
                            aDObjectSearcher.Properties.AddRange(strArrays1);
                            ADObject aDObject3 = aDObjectSearcher.FindOne();
                            if (aDObject3 != null)
                            {
                                value = aDObject3["serverReference"].Value as string;
                            }
                        }
                    }
                    else
                    {
                        value = aDObject1["serverReference"].Value as string;
                    }
                    if (value != null)
                    {
                        ADObjectSearcher aDObjectSearcher1 = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, value, ADSearchScope.Base);
                        using (aDObjectSearcher1)
                        {
                            aDObjectSearcher1.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
                            aDObjectSearcher1.Properties.AddRange(strArrays);
                            aDSessionInfo = aDObjectSearcher1.FindOne();
                            if (aDSessionInfo == null)
                            {
                                DebugLogger.LogInfo("ADDomainControllerFactory", string.Format("GetDirectoryObjectFromIdentity: Identity not found. Filter used: {0}", value));
                                object[] objArray = new object[2];
                                objArray[0] = nTDSSettingsDN;
                                objArray[1] = aDObjectSearcher1.SearchRoot;
                                throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, objArray));
                            }
                        }
                    }
                    else
                    {
                        object[] identity = new object[1];
                        identity[0] = identityObj.Identity;
                        throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.DirectoryServerNotFound, identity));
                    }
                }
                else
                {
                    aDSessionInfo = aDObject;
                }
                aDSessionInfo.TrackChanges = true;
                aDSessionInfo.SessionInfo  = base.CmdletSessionInfo.ADSessionInfo;
                return(aDSessionInfo);
            }
            else
            {
                DebugLogger.LogInfo("ADDomainControllerFactory", string.Format("GetDirectoryObjectFromIdentity: NTDS Settings DN for the given directory server identity not found", new object[0]));
                object[] identity1 = new object[1];
                identity1[0] = identityObj.Identity;
                throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.DirectoryServerNotFound, identity1));
            }
        }
Exemplo n.º 16
0
        internal override T GetExtendedObjectFromIdentity(T identityObj, string identityQueryPath, ICollection <string> propertiesToFetch, bool showDeleted)
        {
            AttributeSetRequest attributeSetRequest;
            string   distinguishedName;
            ADObject domain;

            if (!identityObj.IsSearchResult)
            {
                ADObject aDObject = identityObj;
                if (aDObject != null)
                {
                    if (base.CmdletSessionInfo != null)
                    {
                        attributeSetRequest = this.ConstructAttributeSetRequest(null);
                        attributeSetRequest.DirectoryAttributes.Add("distinguishedName");
                        IADOPathNode   aDOPathNode            = this.BuildIdentityFilter(identityObj);
                        IADOPathNode[] structuralObjectFilter = new IADOPathNode[2];
                        structuralObjectFilter[0] = aDOPathNode;
                        structuralObjectFilter[1] = this.StructuralObjectFilter;
                        aDOPathNode = ADOPathUtil.CreateAndClause(structuralObjectFilter);
                        string           str              = identityQueryPath;
                        ADSearchScope    aDSearchScope    = ADSearchScope.Subtree;
                        bool             flag             = false;
                        ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(base.CmdletSessionInfo.ADSessionInfo, str, aDSearchScope, showDeleted);
                        using (aDObjectSearcher)
                        {
                            aDObjectSearcher.Filter = aDOPathNode;
                            aDObjectSearcher.Properties.AddRange(attributeSetRequest.DirectoryAttributes);
                            DebugLogger.LogInfo(this._debugCategory, string.Format("ADFactory: GetExtendedObjectFromIdentity: Searching for identity using filter: {0} searchbase: {1} scope: {2}", aDObjectSearcher.Filter.GetLdapFilterString(), aDObjectSearcher.SearchRoot, aDObjectSearcher.Scope));
                            ADObject aDObject1 = aDObjectSearcher.FindOne(out flag);
                            if (aDObject1 != null)
                            {
                                if (!flag)
                                {
                                    distinguishedName = aDObject1.DistinguishedName;
                                }
                                else
                                {
                                    throw new ADMultipleMatchingIdentitiesException(StringResources.MultipleMatches);
                                }
                            }
                            else
                            {
                                DebugLogger.LogInfo(this._debugCategory, string.Format("ADFactory: GetExtendedObjectFromIdentity: Identity not found", new object[0]));
                                object[] searchRoot = new object[2];
                                searchRoot[0] = identityObj.ToString();
                                searchRoot[1] = aDObjectSearcher.SearchRoot;
                                throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, searchRoot));
                            }
                        }
                    }
                    else
                    {
                        throw new ArgumentNullException(StringResources.SessionRequired);
                    }
                }
                else
                {
                    object[] type = new object[2];
                    type[0] = "GetExtendedObjectFromIdentity";
                    type[1] = identityObj.GetType();
                    throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, StringResources.MethodNotSupportedForObjectType, type));
                }
            }
            else
            {
                distinguishedName = identityObj.DistinguishedName;
            }
            if (string.Compare(distinguishedName, base.CmdletSessionInfo.ADRootDSE.DefaultNamingContext, StringComparison.OrdinalIgnoreCase) == 0)
            {
                using (ADTopologyManagement aDTopologyManagement = new ADTopologyManagement(base.CmdletSessionInfo.ADSessionInfo))
                {
                    domain = aDTopologyManagement.GetDomain();
                }
                if (domain != null)
                {
                    domain.SessionInfo    = base.CmdletSessionInfo.ADSessionInfo;
                    domain.IsSearchResult = true;
                    attributeSetRequest   = base.ConstructAttributeSetRequest(propertiesToFetch);
                    return(this.Construct(domain, attributeSetRequest));
                }
                else
                {
                    DebugLogger.LogInfo(this._debugCategory, string.Format("GetExtendedObjectFromIdentity: No objects returned from custom action", new object[0]));
                    throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.ObjectNotFound, new object[0]));
                }
            }
            else
            {
                throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.ObjectNotFound, new object[0]));
            }
        }
Exemplo n.º 17
0
        private bool GetADForestCalculateIdentityCSRoutine()
        {
            bool   hasValue;
            bool   flag;
            string value = null;
            string item  = this._cmdletParameters["Server"] as string;
            ADCurrentForestType?nullable = (ADCurrentForestType?)(this._cmdletParameters["Current"] as ADCurrentForestType?);

            if (this._cmdletParameters["Identity"] == null)
            {
                if (!nullable.HasValue)
                {
                    if (item != null || ProviderUtils.IsCurrentDriveAD(base.SessionState))
                    {
                        ADRootDSE        rootDSE          = this.GetRootDSE();
                        string           str              = string.Concat("CN=Partitions,", rootDSE.ConfigurationNamingContext);
                        ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(this.GetSessionInfo(), str, ADSearchScope.OneLevel);
                        using (aDObjectSearcher)
                        {
                            IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2];
                            aDOPathNodeArray[0]     = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "crossRef");
                            aDOPathNodeArray[1]     = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "nCName", rootDSE.RootDomainNamingContext);
                            aDObjectSearcher.Filter = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
                            aDObjectSearcher.Properties.Add("dnsRoot");
                            ADObject aDObject = aDObjectSearcher.FindOne();
                            if (aDObject != null)
                            {
                                value = aDObject["dnsRoot"].Value as string;
                            }
                            if (value == null)
                            {
                                object[] rootDomainNamingContext = new object[1];
                                rootDomainNamingContext[0] = rootDSE.RootDomainNamingContext;
                                throw new ADIdentityResolutionException(string.Format(CultureInfo.CurrentCulture, StringResources.CouldNotFindForestIdentity, rootDomainNamingContext));
                            }
                        }
                    }
                    else
                    {
                        nullable = new ADCurrentForestType?(ADCurrentForestType.LoggedOnUser);
                    }
                }
                ADCurrentForestType?nullable1 = nullable;
                if (nullable1.GetValueOrDefault() != ADCurrentForestType.LocalComputer)
                {
                    hasValue = false;
                }
                else
                {
                    hasValue = nullable1.HasValue;
                }
                if (!hasValue)
                {
                    ADCurrentForestType?nullable2 = nullable;
                    if (nullable2.GetValueOrDefault() != ADCurrentForestType.LoggedOnUser)
                    {
                        flag = false;
                    }
                    else
                    {
                        flag = nullable2.HasValue;
                    }
                    if (!flag)
                    {
                        if (nullable.HasValue)
                        {
                            throw new ArgumentException("Current");
                        }
                    }
                    else
                    {
                        value = base.EffectiveDomainName;
                    }
                }
                else
                {
                    SelectQuery selectQuery = new SelectQuery(WMIConstants.ComputerSystem);
                    ManagementObjectSearcher   managementObjectSearcher              = new ManagementObjectSearcher(selectQuery);
                    ManagementObjectCollection managementObjectCollections           = managementObjectSearcher.Get();
                    ManagementObjectCollection.ManagementObjectEnumerator enumerator = managementObjectCollections.GetEnumerator();
                    using (enumerator)
                    {
                        if (enumerator.MoveNext())
                        {
                            ManagementObject current = (ManagementObject)enumerator.Current;
                            value = current[WMIConstants.Domain] as string;
                        }
                    }
                    if (value == null)
                    {
                        throw new ArgumentException(StringResources.CouldNotDetermineLocalComputerDomain);
                    }
                }
                if (value != null)
                {
                    this._cmdletParameters["Identity"] = new ADForest(value);
                }
                return(true);
            }
            else
            {
                return(true);
            }
        }
 protected bool ADGetPropertiesCmdletBaseProcessCSRoutine()
 {
     if (this._cmdletParameters.Contains("Identity"))
     {
         O item = (O)(this._cmdletParameters["Identity"] as O);
         this.SetPipelinedSessionInfo(item.SessionInfo);
         CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo();
         this._factory.SetCmdletSessionInfo(cmdletSessionInfo);
         this._returnObjectFactory.SetCmdletSessionInfo(cmdletSessionInfo);
         if (this.IdentityLookupMode != IdentityLookupMode.DirectoryMode || this.SourcePropertyType != SourcePropertyType.LinkedDN)
         {
             if (this.IdentityLookupMode != IdentityLookupMode.FactoryMode || this.SourcePropertyType != SourcePropertyType.IdentityInfo)
             {
                 if (this.IdentityLookupMode == IdentityLookupMode.DirectoryMode && this.SourcePropertyType == SourcePropertyType.IdentityInfo)
                 {
                     string identityObjectDN = this.GetIdentityObjectDN();
                     if (identityObjectDN != null)
                     {
                         ADObjectSearcher aDObjectSearcher = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, identityObjectDN, ADSearchScope.Base);
                         using (aDObjectSearcher)
                         {
                             aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
                             aDObjectSearcher.Properties.Add(this.SourceProperty);
                             ADObject aDObject = aDObjectSearcher.FindOne();
                             this.WritePropertiesToOutput(item, aDObject);
                         }
                     }
                 }
             }
             else
             {
                 string[] sourceProperty = new string[1];
                 sourceProperty[0] = this.SourceProperty;
                 O extendedObjectFromIdentity = this._factory.GetExtendedObjectFromIdentity(item, cmdletSessionInfo.DefaultPartitionPath, sourceProperty);
                 this.WritePropertiesToOutput(item, extendedObjectFromIdentity);
             }
         }
         else
         {
             string str = this.GetIdentityObjectDN();
             if (str != null)
             {
                 AttributeSetRequest attributeSetRequest    = this._returnObjectFactory.ConstructAttributeSetRequest(null);
                 ADObjectSearcher    structuralObjectFilter = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, str, ADSearchScope.Base);
                 using (structuralObjectFilter)
                 {
                     structuralObjectFilter.AttributeScopedQuery = this.SourceProperty;
                     structuralObjectFilter.Filter = this._returnObjectFactory.StructuralObjectFilter;
                     structuralObjectFilter.Properties.AddRange(attributeSetRequest.DirectoryAttributes);
                     structuralObjectFilter.AutoRangeRetrieve = this.AutoRangeRetrieve;
                     IEnumerable <ADObject> aDObjects = structuralObjectFilter.FindAll();
                     if (aDObjects != null)
                     {
                         foreach (ADObject aDObject1 in aDObjects)
                         {
                             if (aDObject1 == null)
                             {
                                 continue;
                             }
                             RO rO = this._returnObjectFactory.Construct(aDObject1, attributeSetRequest);
                             base.WriteObject(rO);
                         }
                     }
                 }
             }
         }
     }
     return(true);
 }
        private bool MoveADDSOperationMasterRoleProcessCSRoutine()
        {
            ADObject aDObject;
            bool     flag = false;
            string   value;
            int?     nullable;

            this._identityDSObj = this._cmdletParameters["Identity"] as ADDirectoryServer;
            this._seize         = this._cmdletParameters.GetSwitchParameterBooleanValue("Force");
            this._operationMasterRolesToTransfer = this._cmdletParameters["OperationMasterRole"] as ADOperationMasterRole[];
            base.SetPipelinedSessionInfo(this._identityDSObj.SessionInfo);
            CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo();

            if (cmdletSessionInfo.ConnectedADServerType == ADServerType.ADLDS)
            {
                ADOperationMasterRole[] aDOperationMasterRoleArray = this._operationMasterRolesToTransfer;
                for (int i = 0; i < (int)aDOperationMasterRoleArray.Length; i++)
                {
                    ADOperationMasterRole aDOperationMasterRole  = aDOperationMasterRoleArray[i];
                    ADOperationMasterRole aDOperationMasterRole1 = aDOperationMasterRole;
                    switch (aDOperationMasterRole1)
                    {
                    case ADOperationMasterRole.PDCEmulator:
                    case ADOperationMasterRole.RIDMaster:
                    case ADOperationMasterRole.InfrastructureMaster:
                    {
                        object[] str = new object[1];
                        str[0] = aDOperationMasterRole.ToString();
                        throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.MoveOperationMasterRoleNotApplicableForADLDS, str));
                    }
                    }
                }
            }
            ADDirectoryServerFactory <ADDirectoryServer> aDDirectoryServerFactory = new ADDirectoryServerFactory <ADDirectoryServer>();

            aDDirectoryServerFactory.SetCmdletSessionInfo(cmdletSessionInfo);
            ADObject         directoryObjectFromIdentity = aDDirectoryServerFactory.GetDirectoryObjectFromIdentity(this._identityDSObj, cmdletSessionInfo.DefaultPartitionPath);
            string           distinguishedName           = directoryObjectFromIdentity.DistinguishedName;
            ADObjectSearcher aDObjectSearcher            = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, distinguishedName, ADSearchScope.Base);

            using (aDObjectSearcher)
            {
                aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
                aDObjectSearcher.Properties.Add("dNSHostName");
                directoryObjectFromIdentity = aDObjectSearcher.FindOne();
                if (directoryObjectFromIdentity != null)
                {
                    if (directoryObjectFromIdentity["dNSHostName"] == null)
                    {
                        value = null;
                    }
                    else
                    {
                        value = (string)directoryObjectFromIdentity["dNSHostName"].Value;
                    }
                    string str1 = value;
                    if (!string.IsNullOrEmpty(str1))
                    {
                        if (cmdletSessionInfo.ConnectedADServerType == ADServerType.ADLDS)
                        {
                            string           str2 = string.Concat("CN=NTDS Settings,", distinguishedName);
                            ADObjectSearcher aDObjectSearcher1 = SearchUtility.BuildSearcher(cmdletSessionInfo.ADSessionInfo, str2, ADSearchScope.Base);
                            using (aDObjectSearcher1)
                            {
                                aDObjectSearcher1.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
                                aDObjectSearcher1.Properties.Add("msDS-PortLDAP");
                                aDObject = aDObjectSearcher1.FindOne();
                            }
                            if (aDObject != null)
                            {
                                if (aDObject["msDS-PortLDAP"] == null)
                                {
                                    int?nullable1 = null;
                                    nullable = nullable1;
                                }
                                else
                                {
                                    nullable = (int?)aDObject["msDS-PortLDAP"].Value;
                                }
                                int?nullable2 = nullable;
                                if (nullable2.HasValue)
                                {
                                    str1 = string.Concat(str1, ":", nullable2);
                                }
                                else
                                {
                                    object[] objArray = new object[2];
                                    objArray[0] = "msDS-PortLDAP";
                                    objArray[1] = aDObject.DistinguishedName;
                                    throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.AttributeNotFoundOnObject, objArray));
                                }
                            }
                            else
                            {
                                throw new ADIdentityNotFoundException(string.Concat(StringResources.ObjectNotFound, " : ", str2));
                            }
                        }
                        ADSessionInfo aDSessionInfo = cmdletSessionInfo.ADSessionInfo.Copy();
                        aDSessionInfo.Server = str1;
                        using (ADTopologyManagement aDTopologyManagement = new ADTopologyManagement(aDSessionInfo))
                        {
                            ADOperationMasterRole[] aDOperationMasterRoleArray1 = this._operationMasterRolesToTransfer;
                            for (int j = 0; j < (int)aDOperationMasterRoleArray1.Length; j++)
                            {
                                ADOperationMasterRole aDOperationMasterRole2 = aDOperationMasterRoleArray1[j];
                                string   str3      = string.Format(CultureInfo.CurrentCulture, StringResources.MoveOperationMasterRoleDescription, new object[0]);
                                object[] objArray1 = new object[2];
                                objArray1[0] = aDOperationMasterRole2.ToString();
                                objArray1[1] = str1;
                                string str4 = string.Format(CultureInfo.CurrentCulture, StringResources.MoveOperationMasterRoleWarning, objArray1);
                                string str5 = string.Format(CultureInfo.CurrentCulture, StringResources.MoveOperationMasterRoleCaption, new object[0]);
                                if (base.ShouldProcessOverride(str3, str4, str5))
                                {
                                    aDTopologyManagement.MoveOperationMasterRole(aDOperationMasterRole2, this._seize, out flag);
                                }
                            }
                        }
                    }
                    else
                    {
                        object[] distinguishedName1 = new object[2];
                        distinguishedName1[0] = "dNSHostName";
                        distinguishedName1[1] = directoryObjectFromIdentity.DistinguishedName;
                        throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.AttributeNotFoundOnObject, distinguishedName1));
                    }
                }
                else
                {
                    throw new ADIdentityNotFoundException(string.Concat(StringResources.ObjectNotFound, " : ", distinguishedName));
                }
            }
            return(true);
        }