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)); } }
internal static ADServerType ADServerTypeFromRootDSE(ADRootDSE rootDSE) { if (rootDSE.ServerType == ADServerType.ADLDS) { return(ADServerType.ADLDS); } else { return(ADServerType.ADDS); } }
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 void SetCmdletSessionOptions(ADSessionOptions sessionOptions) { if (this._cmdletSessionOptions != null) { sessionOptions.CopyValuesTo(this._cmdletSessionOptions); } else { this._cmdletSessionOptions = sessionOptions; } this._cachedRootDSE = null; }
protected internal virtual string GetDefaultPartitionPath() { string item; string identifyingString = null; if (this._cmdletParameters.Contains("Partition")) { item = this._cmdletParameters["Partition"] as string; if (!string.IsNullOrEmpty(item)) { ADForestPartitionInfo.ValidatePartitionDN(this.GetRootDSE(), item); return(item); } } if (!this._cmdletParameters.Contains("Identity")) { if (this._cmdletParameters.Contains("Path")) { identifyingString = (string)this._cmdletParameters["Path"]; } } else { ADObject aDObject = this._cmdletParameters["Identity"] as ADObject; if (aDObject != null) { identifyingString = aDObject.IdentifyingString; } } if (identifyingString != null) { ADRootDSE rootDSE = this.GetRootDSE(); item = ADForestPartitionInfo.ExtractPartitionInfo(this.GetRootDSE(), identifyingString, false); if (item == null && rootDSE.SessionInfo.ConnectedToGC) { item = ADForestPartitionInfo.ExtractPartitionInfo(this.GetRootDSE(), identifyingString, true); } if (item != null) { return(item); } } if (!this._cmdletParameters.Contains("Server") && this._pipelineSessionInfo == null && ProviderUtils.IsCurrentDriveAD(base.SessionState)) { string currentPartitionPath = ProviderUtils.GetCurrentPartitionPath(base.SessionState); if (!string.IsNullOrEmpty(currentPartitionPath)) { return(currentPartitionPath); } } return(this.GetDefaultPartitionPathBase()); }
public CmdletSessionInfo(ADSessionInfo adSessionInfo, ADRootDSE adRootDse, string defaultQueryPath, string defaultPartitionPath, string defaultCreationPath, ADServerType connectedADServerType, IADCmdletCache cmdletSessionCache, IADCmdletMessageWriter cmdletMessageWriter, PSCmdlet psCmdlet, ADParameterSet cmdletParameters) { this._adSessionInfo = adSessionInfo; this._adRootDse = adRootDse; this._defaultQueryPath = defaultQueryPath; this._defaultPartitionPath = defaultPartitionPath; this._defaultCreationPath = defaultCreationPath; this._connectedADServerType = connectedADServerType; this._cmdletSessionCache = cmdletSessionCache; this._cmdletMessageWriter = cmdletMessageWriter; this._psCmdlet = psCmdlet; this._cmdletParameters = cmdletParameters; }
protected internal virtual ADRootDSE GetRootDSE() { if (this._cachedRootDSE == null) { ADSessionInfo sessionInfo = this.GetSessionInfo(); using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo)) { this._cachedRootDSE = aDObjectSearcher.GetRootDSE(); this._cachedRootDSE.SessionInfo = sessionInfo; } this._connectedStore = new ADServerType?(Utils.ADServerTypeFromRootDSE(this._cachedRootDSE)); } return(this._cachedRootDSE); }
private bool GetGroupMembershipProcessCSRoutine() { this._partitionPath = this._cmdletParameters["Partition"] as string; this._identityADPrincipal = this._cmdletParameters["Identity"] as ADPrincipal; base.SetPipelinedSessionInfo(this._identityADPrincipal.SessionInfo); CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo(); ADPrincipalFactory <ADPrincipal> aDPrincipalFactory = new ADPrincipalFactory <ADPrincipal>(); aDPrincipalFactory.SetCmdletSessionInfo(cmdletSessionInfo); this.ValidateParameters(); ADObject directoryObjectFromIdentity = aDPrincipalFactory.GetDirectoryObjectFromIdentity(this._identityADPrincipal, cmdletSessionInfo.DefaultPartitionPath); using (ADAccountManagement aDAccountManagement = new ADAccountManagement(cmdletSessionInfo.ADSessionInfo)) { if (!string.IsNullOrEmpty(this._resourceContextServer) && string.IsNullOrEmpty(this._resourceContextPartition)) { ADSessionInfo aDSessionInfo = cmdletSessionInfo.ADSessionInfo.Copy(); aDSessionInfo.Server = this._resourceContextServer; using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(aDSessionInfo)) { ADRootDSE rootDSE = aDObjectSearcher.GetRootDSE(); if (rootDSE.DefaultNamingContext != null) { this._resourceContextPartition = rootDSE.DefaultNamingContext; } else { object[] objArray = new object[1]; objArray[0] = "ResourceContextPartition"; base.ThrowTerminatingError(new ErrorRecord(new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ParameterRequired, objArray)), "1", ErrorCategory.InvalidArgument, null)); } } } ADGroup[] principalGroupMembership = aDAccountManagement.GetPrincipalGroupMembership(cmdletSessionInfo.DefaultPartitionPath, directoryObjectFromIdentity.DistinguishedName, this._resourceContextServer, this._resourceContextPartition); ADGroup[] aDGroupArray = principalGroupMembership; for (int i = 0; i < (int)aDGroupArray.Length; i++) { ADGroup aDGroup = aDGroupArray[i]; base.WriteObject(aDGroup); } } return(true); }
private bool GetADRootDSEBeginCSRoutine() { bool flag; Collection <string> strs = new Collection <string>(); string[] item = this._cmdletParameters["Properties"] as string[]; strs.Add("*"); if (item != null) { for (int i = 0; i < (int)item.Length; i++) { strs.Add(item[i]); } } ADObjectSearcher aDObjectSearcher = null; using (aDObjectSearcher) { try { aDObjectSearcher = new ADObjectSearcher(this.GetSessionInfo()); ADRootDSE rootDSE = aDObjectSearcher.GetRootDSE(strs); rootDSE.SessionInfo = base.GetCmdletSessionInfo().ADSessionInfo; base.WriteObject(rootDSE); flag = true; } catch (ADException aDException1) { ADException aDException = aDException1; base.WriteError(ADUtilities.GetErrorRecord(aDException, "GetADRootDSE:BeginProcessing:ADError", null)); flag = false; } catch (AuthenticationException authenticationException1) { AuthenticationException authenticationException = authenticationException1; base.WriteError(ADUtilities.GetErrorRecord(authenticationException, "GetADRootDSE:BeginProcessing:InvalidCredentials", null)); flag = false; } } return(flag); }
private bool ADMoveCmdletBaseProcessCSRoutine() { bool flag; O item = (O)this._cmdletParameters["Identity"]; this.SetPipelinedSessionInfo(item.SessionInfo); CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo(); this._factory.SetCmdletSessionInfo(cmdletSessionInfo); this.ValidateParameters(); string defaultPartitionPath = this.GetDefaultPartitionPath(); ADObject directoryObjectFromIdentity = this._factory.GetDirectoryObjectFromIdentity(item, defaultPartitionPath); using (ADActiveObject aDActiveObject = new ADActiveObject(cmdletSessionInfo.ADSessionInfo, directoryObjectFromIdentity)) { if (base.ShouldProcessOverride(directoryObjectFromIdentity.DistinguishedName, "Move")) { O o = default(O); if (this._factory.PreCommitProcesing(ADFactory <O> .DirectoryOperation.Move, o, this._cmdletParameters, directoryObjectFromIdentity)) { aDActiveObject.Update(); } string str = this._cmdletParameters["TargetPath"] as string; string childName = ADPathModule.GetChildName(directoryObjectFromIdentity.DistinguishedName, ADPathFormat.X500); string item1 = null; if (!this._cmdletParameters.Contains("TargetServer")) { aDActiveObject.Move(str, childName); } else { item1 = this._cmdletParameters["TargetServer"] as string; aDActiveObject.CrossDomainMove(str, childName, item1); } O o1 = default(O); this._factory.PostCommitProcesing(ADFactory <O> .DirectoryOperation.Move, o1, this._cmdletParameters, directoryObjectFromIdentity); if (this._cmdletParameters.GetSwitchParameterBooleanValue("PassThru")) { ADSessionInfo aDSessionInfo = cmdletSessionInfo.ADSessionInfo; if (this._cmdletParameters.Contains("TargetServer")) { aDSessionInfo.Server = item1; } string str1 = ADPathModule.MakePath(str, childName, ADPathFormat.X500); F f = Activator.CreateInstance <F>(); using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(aDSessionInfo)) { ADRootDSE rootDSE = aDObjectSearcher.GetRootDSE(); ADCmdletCache aDCmdletCache = new ADCmdletCache(); aDSessionInfo.ServerType = Utils.ADServerTypeFromRootDSE(rootDSE); CmdletSessionInfo cmdletSessionInfo1 = new CmdletSessionInfo(aDSessionInfo, rootDSE, rootDSE.DefaultNamingContext, rootDSE.DefaultNamingContext, rootDSE.DefaultNamingContext, aDSessionInfo.ServerType, aDCmdletCache, this, this, this._cmdletParameters); f.SetCmdletSessionInfo(cmdletSessionInfo1); O extendedObjectFromDN = this._factory.GetExtendedObjectFromDN(str1); base.WriteObject(extendedObjectFromDN); aDCmdletCache.Clear(); } } return(true); } else { flag = false; } } return(flag); }
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); } }
private bool ADGetDomainCmdletBaseCalculateIdentityCSRoutine() { bool hasValue; bool flag; if (this._cmdletParameters["Identity"] == null) { string defaultNamingContext = null; string item = this._cmdletParameters["Server"] as string; ADCurrentDomainType?nullable = (ADCurrentDomainType?)(this._cmdletParameters["Current"] as ADCurrentDomainType?); if (!nullable.HasValue) { if (item != null || ProviderUtils.IsCurrentDriveAD(base.SessionState)) { ADRootDSE rootDSE = this.GetRootDSE(); defaultNamingContext = rootDSE.DefaultNamingContext; } else { nullable = new ADCurrentDomainType?(ADCurrentDomainType.LoggedOnUser); } } ADCurrentDomainType?nullable1 = nullable; if (nullable1.GetValueOrDefault() != ADCurrentDomainType.LocalComputer) { hasValue = false; } else { hasValue = nullable1.HasValue; } if (!hasValue) { ADCurrentDomainType?nullable2 = nullable; if (nullable2.GetValueOrDefault() != ADCurrentDomainType.LoggedOnUser) { flag = false; } else { flag = nullable2.HasValue; } if (!flag) { if (nullable.HasValue) { throw new ArgumentException("Current"); } } else { defaultNamingContext = base.EffectiveDomainName; } } else { defaultNamingContext = ADDomainUtil.GetLocalComputerDomain(); if (defaultNamingContext == null) { throw new ArgumentException(StringResources.CouldNotDetermineLocalComputerDomain); } } if (defaultNamingContext != null) { this._cmdletParameters["Identity"] = this.ConstructObjectFromIdentity(defaultNamingContext); } return(true); } else { return(true); } }
internal virtual void SetPipelinedSessionInfo(ADSessionInfo session) { this._pipelineSessionInfo = session; this._cachedRootDSE = null; }
private void SetDefaultSessionInfo(ADSessionInfo session) { this._sessionInfo = session; this._cachedRootDSE = null; }
private void ValidateMemberOfParameter() { ADGroup extendedObjectFromIdentity; if (!this._isMemberOfValidated) { this._validExtendedGroupPartitionPairList = new List <SetADPrincipalGroupMembership <P> .ADGroupPartitionDNPair>(); object item = this._cmdletParameters["MemberOf"]; ADPrincipal[] aDPrincipalArray = item as ADGroup[]; if (aDPrincipalArray == null) { ADGroup aDGroup = item as ADGroup; if (aDGroup != null) { ADGroup[] aDGroupArray = new ADGroup[1]; aDGroupArray[0] = aDGroup; aDPrincipalArray = aDGroupArray; } } if (aDPrincipalArray != null) { new Hashtable(); ADGroupFactory <ADGroup> aDGroupFactory = new ADGroupFactory <ADGroup>(); CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo(); aDGroupFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADPrincipal[] aDPrincipalArray1 = aDPrincipalArray; for (int i = 0; i < (int)aDPrincipalArray1.Length; i++) { ADGroup aDGroup1 = (ADGroup)aDPrincipalArray1[i]; try { if (!aDGroup1.IsSearchResult) { extendedObjectFromIdentity = aDGroupFactory.GetExtendedObjectFromIdentity(aDGroup1, cmdletSessionInfo.DefaultPartitionPath); this._validExtendedGroupPartitionPairList.Add(new SetADPrincipalGroupMembership <P> .ADGroupPartitionDNPair(extendedObjectFromIdentity)); } else { extendedObjectFromIdentity = aDGroup1; using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(extendedObjectFromIdentity.SessionInfo)) { ADRootDSE rootDSE = aDObjectSearcher.GetRootDSE(); string str = ADForestPartitionInfo.ExtractAndValidatePartitionInfo(rootDSE, extendedObjectFromIdentity.DistinguishedName); this._validExtendedGroupPartitionPairList.Add(new SetADPrincipalGroupMembership <P> .ADGroupPartitionDNPair(extendedObjectFromIdentity, str)); } } } catch (ADIdentityNotFoundException aDIdentityNotFoundException1) { ADIdentityNotFoundException aDIdentityNotFoundException = aDIdentityNotFoundException1; DebugLogger.LogError("SetADPrincipalGroupMembership", aDIdentityNotFoundException.ToString()); base.ThrowTerminatingError(new ErrorRecord(aDIdentityNotFoundException, "SetADPrincipalGroupMembership:ValidateMemberOfParameter", ErrorCategory.ObjectNotFound, aDGroup1)); } } } this._isMemberOfValidated = true; return; } else { return; } }
private bool ModifyADOptionalFeatureBaseProcessCSRoutine() { string distinguishedName; string str; string str1 = null; bool flag; if (this._cmdletParameters.Contains("Identity")) { ADOptionalFeature item = this._cmdletParameters["Identity"] as ADOptionalFeature; ADOptionalFeatureScope aDOptionalFeatureScope = (ADOptionalFeatureScope)this._cmdletParameters["Scope"]; ADEntity aDEntity = this._cmdletParameters["Target"] as ADEntity; this.SetPipelinedSessionInfo(item.SessionInfo); CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo(); this._factory.SetCmdletSessionInfo(cmdletSessionInfo); if (aDOptionalFeatureScope != ADOptionalFeatureScope.Domain) { if (aDOptionalFeatureScope != ADOptionalFeatureScope.ForestOrConfigurationSet) { distinguishedName = null; } else { string item1 = this._cmdletParameters["Server"] as string; ADRootDSE rootDSE = this.GetRootDSE(); if (rootDSE.ServerType != ADServerType.ADDS) { cmdletSessionInfo = this.GetCmdletSessionInfo(); ADObjectFactory <ADObject> aDObjectFactory = new ADObjectFactory <ADObject>(); aDObjectFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADObject aDObject = new ADObject(); aDObject.Identity = aDEntity.Identity; ADObject directoryObjectFromIdentity = aDObjectFactory.GetDirectoryObjectFromIdentity(aDObject, rootDSE.ConfigurationNamingContext, false); string str2 = X500Path.StripX500Whitespace(directoryObjectFromIdentity.DistinguishedName); if (string.Compare(rootDSE.ConfigurationNamingContext, str2, StringComparison.InvariantCultureIgnoreCase) == 0) { distinguishedName = string.Concat("CN=Partitions,", directoryObjectFromIdentity.DistinguishedName); } else { object[] objArray = new object[1]; objArray[0] = aDEntity.Identity.ToString(); throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.ConfigSetNotFound, objArray)); } } else { ADRootDSE aDRootDSE = null; if (item1 != null) { aDRootDSE = rootDSE; } if (aDEntity as ADForest == null) { str = ADDomainUtil.DiscoverDCFromIdentity <ADForest>(aDEntity.Identity, out str1); } else { str = ADDomainUtil.DiscoverDCFromIdentity <ADForest>(aDEntity, out str1); } if (str != null) { ADSessionInfo sessionInfo = this.GetSessionInfo(); sessionInfo.Server = str1; this.SetPipelinedSessionInfo(sessionInfo); if (aDRootDSE != null) { ADRootDSE rootDSE1 = this.GetRootDSE(); if (rootDSE1.RootDomainNamingContext == aDRootDSE.RootDomainNamingContext) { sessionInfo.Server = item1; this.SetPipelinedSessionInfo(sessionInfo); } else { throw new ADIdentityNotFoundException(); } } base.TargetOperationMasterRole(ADOperationMasterRole.DomainNamingMaster); cmdletSessionInfo = this.GetCmdletSessionInfo(); this._factory.SetCmdletSessionInfo(cmdletSessionInfo); ADForestFactory <ADForest> aDForestFactory = new ADForestFactory <ADForest>(); aDForestFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADForest aDForest = new ADForest(str1); ADObject directoryObjectFromIdentity1 = aDForestFactory.GetDirectoryObjectFromIdentity(aDForest, this.GetRootDSE().DefaultNamingContext, false); distinguishedName = directoryObjectFromIdentity1.DistinguishedName; } else { object[] defaultNamingContext = new object[2]; defaultNamingContext[0] = aDEntity.Identity.ToString(); defaultNamingContext[1] = this.GetRootDSE().DefaultNamingContext; throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.IdentityNotFound, defaultNamingContext)); } } } } else { ADDomainFactory <ADDomain> aDDomainFactory = new ADDomainFactory <ADDomain>(); aDDomainFactory.SetCmdletSessionInfo(cmdletSessionInfo); ADDomain aDDomain = new ADDomain(); if (aDEntity as ADObject == null) { aDDomain = new ADDomain(aDEntity.Identity as string); } else { aDDomain.Identity = aDEntity; } ADObject aDObject1 = aDDomainFactory.GetDirectoryObjectFromIdentity(aDDomain, this.GetRootDSE().DefaultNamingContext, false); distinguishedName = aDObject1.DistinguishedName; } this.ValidateParameters(); item = this._factory.GetExtendedObjectFromIdentity(item, this.GetDefaultPartitionPath(), null, false); Guid? featureGUID = item.FeatureGUID; string str3 = featureGUID.ToString(); if (this._action != ModifyADOptionalFeatureBase <P> .ModifyADOptionalFeatureAction.Enable) { if (this._action != ModifyADOptionalFeatureBase <P> .ModifyADOptionalFeatureAction.Disable) { throw new NotImplementedException(this._action.ToString()); } else { flag = false; } } else { if (!item.IsDisableable) { base.WriteWarning(string.Format(StringResources.EnablingIsIrreversible, item.Name, distinguishedName)); } flag = true; } if (base.ShouldProcessOverride(item.Name, this._action.ToString())) { using (ADTopologyManagement aDTopologyManagement = new ADTopologyManagement(cmdletSessionInfo.ADSessionInfo)) { aDTopologyManagement.ChangeOptionalFeature(distinguishedName, flag, str3); } return(true); } else { return(false); } } else { object[] objArray1 = new object[1]; objArray1[0] = "Identity,Instance"; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ParameterRequiredMultiple, objArray1)); } }