private bool ADNewCmdletBaseProcessCSRoutine() { bool flag; this.ValidateParameters(); CmdletSessionInfo cmdletSessionInfo = this.GetCmdletSessionInfo(); this._factory.SetCmdletSessionInfo(cmdletSessionInfo); string item = this._cmdletParameters["Path"] as string; if (string.IsNullOrEmpty(item)) { item = this.GetDefaultCreationPath(); if (string.IsNullOrEmpty(item)) { object[] objArray = new object[1]; objArray[0] = "Path"; throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ParameterRequired, objArray)); } } string str = this.GenerateObjectClass(this._factory, this._cmdletParameters, this._cmdletParameters); string str1 = this.GenerateDN(this._factory, this._cmdletParameters, this._cmdletParameters, item); this._currentIdentity = str1; ADObject aDObject = new ADObject(str1, str); using (ADActiveObject aDActiveObject = new ADActiveObject(cmdletSessionInfo.ADSessionInfo, aDObject)) { if (base.ShouldProcessOverride(aDObject.DistinguishedName, "New")) { this._factory.UpdateFromParameters(this._defaultParamSet, null, null, null, null, aDObject); if (this._cmdletParameters.Contains("Instance")) { this._factory.UpdateFromTemplate((O)(this._cmdletParameters["Instance"] as O), aDObject); } this._factory.UpdateFromParameters(this._cmdletParameters, null, this._cmdletParameters["OtherAttributes"] as Hashtable, null, null, aDObject); this._factory.PreCommitProcesing(ADFactory <O> .DirectoryOperation.Create, (O)(this._cmdletParameters["Instance"] as O), this._cmdletParameters, aDObject); aDActiveObject.Create(); aDObject.TrackChanges = true; bool flag1 = this._factory.PostCommitProcesing(ADFactory <O> .DirectoryOperation.Create, (O)(this._cmdletParameters["Instance"] as O), this._cmdletParameters, aDObject); if (flag1) { aDActiveObject.Update(); } if (this._cmdletParameters.GetSwitchParameterBooleanValue("PassThru")) { O extendedObjectFromDN = this._factory.GetExtendedObjectFromDN(aDObject.DistinguishedName); base.WriteObject(extendedObjectFromDN); } return(true); } else { flag = false; } } return(flag); }
private void CreateServerContainer(string siteDN) { string str = ADPathModule.MakePath(siteDN, "CN=Servers,", ADPathFormat.X500); ADObject aDObject = new ADObject(str, "serversContainer"); using (ADActiveObject aDActiveObject = new ADActiveObject(base.CmdletSessionInfo.ADSessionInfo, aDObject)) { aDActiveObject.Create(); } }
private void CreateSiteChildObjects(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj) { AttributeConverterEntry attributeConverterEntry = null; bool flag = ADFactory <T> .DirectoryOperation.Create == operation; MappingTable <AttributeConverterEntry> item = ADNtdsSiteSettingFactory <ADNtdsSiteSetting> .AttributeTable[base.ConnectedStore]; MappingTable <AttributeConverterEntry> mappingTable = ADReplicationSiteFactory <T> .AttributeTable[base.ConnectedStore]; IDictionary <string, ADPropertyValueCollection> strs = new Dictionary <string, ADPropertyValueCollection>(); if (instance != null) { foreach (string propertyName in instance.PropertyNames) { if (flag && instance[propertyName].Value == null || mappingTable.TryGetValue(propertyName, out attributeConverterEntry) || !item.TryGetValue(propertyName, out attributeConverterEntry)) { continue; } strs.Add(propertyName, instance[propertyName]); } } IDictionary <string, ADPropertyValueCollection> aDPVCDictionary = parameters.GetADPVCDictionary(); foreach (string key in aDPVCDictionary.Keys) { if (mappingTable.TryGetValue(key, out attributeConverterEntry) || !item.TryGetValue(key, out attributeConverterEntry)) { continue; } if (!strs.ContainsKey(key)) { strs.Add(key, aDPVCDictionary[key]); } else { strs[key] = aDPVCDictionary[key]; } } string str = ADPathModule.MakePath(directoryObj.DistinguishedName, "CN=NTDS Site Settings,", ADPathFormat.X500); ADNtdsSiteSettingFactory <ADNtdsSiteSetting> aDNtdsSiteSettingFactory = new ADNtdsSiteSettingFactory <ADNtdsSiteSetting>(); aDNtdsSiteSettingFactory.SetCmdletSessionInfo(base.CmdletSessionInfo); ADObject directoryObjectFromIdentity = null; if (!flag) { try { ADNtdsSiteSetting aDNtdsSiteSetting = new ADNtdsSiteSetting(str); directoryObjectFromIdentity = aDNtdsSiteSettingFactory.GetDirectoryObjectFromIdentity(aDNtdsSiteSetting, directoryObj.DistinguishedName); } catch (ADIdentityNotFoundException aDIdentityNotFoundException) { DebugLogger.LogInfo(this._debugCategory, string.Format("ADReplicationSiteFactory: Ntds-Site-Setting object not found for the site {0}, while updating the properties of the ntds-site-settings", directoryObj.DistinguishedName)); } } if (directoryObjectFromIdentity == null) { flag = true; directoryObjectFromIdentity = new ADObject(str, aDNtdsSiteSettingFactory.StructuralObjectClass); } foreach (string key1 in strs.Keys) { if (!item.TryGetValue(key1, out attributeConverterEntry) || !attributeConverterEntry.IsDirectoryConverterDefined) { continue; } attributeConverterEntry.InvokeToDirectoryConverter(strs[key1], directoryObjectFromIdentity, base.CmdletSessionInfo); } using (ADActiveObject aDActiveObject = new ADActiveObject(base.CmdletSessionInfo.ADSessionInfo, directoryObjectFromIdentity)) { if (!flag) { aDActiveObject.Update(); } else { aDActiveObject.Create(); } } if (operation == ADFactory <T> .DirectoryOperation.Create) { this.CreateServerContainer(directoryObj.DistinguishedName); } }