예제 #1
0
 internal static void InsertClaimTransformRule(ADParameterSet parameters, CmdletSessionInfo cmdletSessionInfo)
 {
     if (parameters.GetSwitchParameterBooleanValue("DenyAll"))
     {
         parameters["Rule"] = ADCBACUtil.CreateClaimTransformDenyRule(null);
     }
     if (!parameters.GetSwitchParameterBooleanValue("AllowAll"))
     {
         if (!parameters.Contains("AllowAllExcept") || parameters["AllowAllExcept"] == null)
         {
             if (parameters.Contains("DenyAllExcept") && parameters["DenyAllExcept"] != null)
             {
                 string[] claimTypeName = ADCBACUtil.GetClaimTypeName((ADClaimType[])parameters["DenyAllExcept"], cmdletSessionInfo, "DenyAllExcept");
                 parameters["Rule"] = ADCBACUtil.CreateClaimTransformDenyRule(claimTypeName);
             }
             return;
         }
         else
         {
             string[] strArrays = ADCBACUtil.GetClaimTypeName((ADClaimType[])parameters["AllowAllExcept"], cmdletSessionInfo, "AllowAllExcept");
             parameters["Rule"] = ADCBACUtil.CreateClaimTransformAllowRule(strArrays);
             return;
         }
     }
     else
     {
         parameters["Rule"] = ADCBACUtil.CreateClaimTransformAllowRule(null);
         return;
     }
 }
예제 #2
0
        protected internal virtual string GenerateNewRDN(F factory, ADParameterSet cmdletParameters, P dynamicParameters, string oldDN)
        {
            string str  = this.GenerateRDNPrefix(factory, cmdletParameters, dynamicParameters, oldDN);
            string item = cmdletParameters["NewName"] as string;

            if (item != null)
            {
                item = Utils.EscapeDNComponent(item);
            }
            return(string.Concat(str, "=", item));
        }
예제 #3
0
        protected internal virtual string GenerateRDN(F factory, ADParameterSet cmdletParameters, P dynamicParameters)
        {
            string str  = this.GenerateRDNPrefix(factory, cmdletParameters, dynamicParameters);
            string str1 = factory.GenerateObjectName(dynamicParameters);

            if (str1 != null)
            {
                str1 = Utils.EscapeDNComponent(str1);
            }
            return(string.Concat(str, "=", str1));
        }
예제 #4
0
 internal override string GenerateObjectName(ADParameterSet parameters)
 {
     if (parameters.Contains("ID"))
     {
         ADCBACUtil.ValidateClaimID(parameters["ID"] as string);
         return(parameters["ID"] as string);
     }
     else
     {
         return(ADCBACUtil.GenerateClaimID(parameters["DisplayName"] as string));
     }
 }
예제 #5
0
 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;
 }
예제 #6
0
 private bool ADServiceAccountPreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
 {
     if (string.CompareOrdinal(directoryObj.ObjectClass, "msDS-ManagedServiceAccount") != 0)
     {
         ADAccountFactory <T> .UseComputerPasswordGeneration = false;
     }
     return(false);
 }
예제 #7
0
        private bool ADResourcePropertyPreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
        {
            if (operation == ADFactory <T> .DirectoryOperation.Create || ADFactory <T> .DirectoryOperation.Update == operation)
            {
                bool          flag          = true;
                ADObject      aDObject      = null;
                StringBuilder stringBuilder = new StringBuilder();
                flag = flag & ADResourcePropertyFactory <T> .VerifyResourcePropertyValueType(directoryObj, base.CmdletSessionInfo, out aDObject, stringBuilder);

                if (aDObject != null && aDObject.Contains("ValueType"))
                {
                    ADClaimValueType?value = (ADClaimValueType?)(aDObject["ValueType"].Value as ADClaimValueType?);
                    flag = flag & ADCBACUtil.VerifyAndSetPossibleValues(directoryObj, value.Value, stringBuilder);
                }
                flag = flag & ADResourcePropertyFactory <T> .VerifySharesPossibleValueWithAndPossibleValueExclusiveness(directoryObj, operation, stringBuilder);

                flag = flag & ADResourcePropertyFactory <T> .VerifyIsSuggestedValuePresentAttribute(directoryObj, stringBuilder, aDObject);

                flag = flag & ADResourcePropertyFactory <T> .VerifySharesValuesWith(directoryObj, stringBuilder, aDObject, base.CmdletSessionInfo);

                if (flag)
                {
                    return(false);
                }
                else
                {
                    stringBuilder.AppendLine(StringResources.CTParameterValidationFailure);
                    throw new ADException(stringBuilder.ToString());
                }
            }
            else
            {
                return(false);
            }
        }
예제 #8
0
 private bool ADReplicationSiteRemovePreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
 {
     if (ADFactory <T> .DirectoryOperation.Delete == operation)
     {
         ADObjectFactory <ADObject> aDObjectFactory = new ADObjectFactory <ADObject>();
         aDObjectFactory.SetCmdletSessionInfo(base.CmdletSessionInfo);
         IADOPathNode           aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "server");
         int?                   nullable    = null;
         int?                   nullable1   = null;
         IEnumerable <ADObject> extendedObjectFromFilter = aDObjectFactory.GetExtendedObjectFromFilter(aDOPathNode, directoryObj.DistinguishedName, ADSearchScope.Subtree, null, nullable, nullable1, false);
         IEnumerator <ADObject> enumerator = extendedObjectFromFilter.GetEnumerator();
         using (enumerator)
         {
             if (enumerator.MoveNext())
             {
                 //TODO: Review: URGENT!! : enumerator.Current;
                 object[] distinguishedName = new object[1];
                 distinguishedName[0] = directoryObj.DistinguishedName;
                 throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.ServerContainerNotEmpty, distinguishedName));
             }
         }
         return(false);
     }
     else
     {
         return(false);
     }
 }
예제 #9
0
 private bool ADReplicationSitePostCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
 {
     if (ADFactory <T> .DirectoryOperation.Update == operation || operation == ADFactory <T> .DirectoryOperation.Create)
     {
         try
         {
             this.CreateSiteChildObjects(operation, instance, parameters, directoryObj);
         }
         catch (Exception exception3)
         {
             Exception exception = exception3;
             if (operation == ADFactory <T> .DirectoryOperation.Create && (exception as ADException != null || exception as ADInvalidOperationException != null || exception as ADIdentityResolutionException != null || exception as UnauthorizedAccessException != null || exception as ArgumentException != null))
             {
                 try
                 {
                     this.RemoveADReplicationSite(directoryObj);
                 }
                 catch (Exception exception2)
                 {
                     Exception exception1 = exception2;
                     DebugLogger.LogWarning(this._debugCategory, string.Format("ADReplicationSiteFactory: Unable to delete the Site {0}. Deletion failed with error {1}.", directoryObj.DistinguishedName, exception1.Message));
                 }
             }
             throw;
         }
         return(false);
     }
     else
     {
         return(false);
     }
 }
예제 #10
0
 protected internal override string GenerateObjectClass(ADObjectFactory <ADObject> factory, ADParameterSet cmdletParameters, NewADObjectParameterSet dynamicParameters)
 {
     return(dynamicParameters.Type);
 }
 private bool ADCentralAccessRulePreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
 {
     if (ADFactory <T> .DirectoryOperation.Update == operation)
     {
         if (directoryObj.ModifiedProperties.Contains("msAuthz-EffectiveSecurityPolicy") || directoryObj.RemovedProperties.Contains("msAuthz-EffectiveSecurityPolicy") || directoryObj.AddedProperties.Contains("msAuthz-EffectiveSecurityPolicy"))
         {
             string str = ADPathModule.MakePath(base.CmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Central Access Rules,CN=Claims Configuration,CN=Services,", ADPathFormat.X500);
             string attributeValueFromObjectName = AttributeConverters.GetAttributeValueFromObjectName <ADCentralAccessRuleFactory <ADCentralAccessRule>, ADCentralAccessRule>(directoryObj.DistinguishedName, str, "CurrentAcl", "PreviousAcl", base.CmdletSessionInfo) as string;
             directoryObj["msAuthz-LastEffectiveSecurityPolicy"].Value = attributeValueFromObjectName;
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #12
0
 protected internal virtual string GenerateRDNPrefix(F factory, ADParameterSet cmdletParameters, P dynamicParameters, string oldDN)
 {
     return(factory.RDNPrefix);
 }
예제 #13
0
 private bool ADGroupPreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
 {
     if (operation != ADFactory <T> .DirectoryOperation.Create || instance != null || parameters.Contains("GroupCategory"))
     {
         return(false);
     }
     else
     {
         directoryObj["groupType"].Value = (int)directoryObj["groupType"].Value | -2147483648;
         return(true);
     }
 }
예제 #14
0
 protected internal virtual string GenerateObjectClass(F factory, ADParameterSet cmdletParameters, P dynamicParameters)
 {
     return(factory.StructuralObjectClass);
 }
예제 #15
0
        protected internal virtual string GenerateDN(F factory, ADParameterSet cmdletParameters, P dynamicParameters, string path)
        {
            string str = this.GenerateRDN(factory, cmdletParameters, dynamicParameters);

            return(string.Concat(str, ",", path));
        }
예제 #16
0
        private bool ADDomainPreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
        {
            bool flag = false;

            if (operation == ADFactory <T> .DirectoryOperation.Update && base.PropertyHasChange(ADDomainFactory <T> .ADDomainPropertyMap.DomainMode.PropertyName, instance, parameters, operation))
            {
                ADDomainMode?singleValueProperty = base.GetSingleValueProperty <ADDomainMode?>(ADDomainFactory <T> .ADDomainPropertyMap.DomainMode.PropertyName, instance, parameters, operation);
                if (singleValueProperty.HasValue)
                {
                    ADDomainMode value = singleValueProperty.Value;
                    switch (value)
                    {
                    case ADDomainMode.Windows2000Domain:
                    {
                        Win32Exception win32Exception = new Win32Exception(50);
                        throw new NotSupportedException(win32Exception.Message);
                    }

                    case ADDomainMode.Windows2003InterimDomain:
                    {
                        if (base.CmdletSessionInfo.ADRootDSE.DomainFunctionality == ADDomainMode.Windows2000Domain && ADDomainFactory <T> .GetNTMixedDomainMode(base.CmdletSessionInfo) == 1)
                        {
                            break;
                        }
                        directoryObj["ntMixedDomain"].Value = 1;
                        flag = true;
                        break;
                    }

                    case ADDomainMode.Windows2003Domain:
                    {
                        bool flag1 = false;
                        if (base.CmdletSessionInfo.ADRootDSE.DomainFunctionality != ADDomainMode.Windows2000Domain)
                        {
                            if (base.CmdletSessionInfo.ADRootDSE.DomainFunctionality == ADDomainMode.Windows2003InterimDomain)
                            {
                                flag1 = true;
                            }
                        }
                        else
                        {
                            if (ADDomainFactory <T> .GetNTMixedDomainMode(base.CmdletSessionInfo) != 0)
                            {
                                flag1 = true;
                            }
                        }
                        if (!flag1)
                        {
                            break;
                        }
                        ADDomainFactory <T> .UpdateNTMixedDomainMode(base.CmdletSessionInfo, 0);

                        break;
                    }
                    }
                }
                else
                {
                    return(flag);
                }
            }
            return(flag);
        }
예제 #17
0
		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;
		}
예제 #18
0
 protected internal override string GenerateObjectClass(ADServiceAccountFactory <ADServiceAccount> factory, ADParameterSet cmdletParameters, NewADServiceAccountParameterSet dynamicParameters)
 {
     if (!cmdletParameters.GetSwitchParameterBooleanValue("RestrictToSingleComputer"))
     {
         return("msDS-GroupManagedServiceAccount");
     }
     else
     {
         return("msDS-ManagedServiceAccount");
     }
 }
 private bool ADReplicationSiteLinkPreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
 {
     if (operation == ADFactory <T> .DirectoryOperation.Create)
     {
         if (!directoryObj.Contains("siteList") || directoryObj["siteList"].Count <= 1)
         {
             object[] objArray = new object[4];
             objArray[0] = "SiteLink";
             objArray[1] = 2;
             objArray[2] = "Sites";
             objArray[3] = "SitesIncluded";
             throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.ADInvalidAttributeValueCount, objArray));
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
예제 #20
0
        protected internal override string GenerateObjectClass(ADUserFactory <ADUser> factory, ADParameterSet cmdletParameters, NewADUserParameterSet dynamicParameters)
        {
            string item = null;

            if (dynamicParameters != null && dynamicParameters.Contains("Type"))
            {
                item = (string)dynamicParameters["Type"];
                if (item != null)
                {
                    ADSchemaUtil     aDSchemaUtil   = new ADSchemaUtil(this.GetCmdletSessionInfo().ADSessionInfo);
                    HashSet <string> userSubClasses = aDSchemaUtil.GetUserSubClasses();
                    if (!userSubClasses.Contains(item))
                    {
                        throw new ArgumentException(string.Format(StringResources.UnsupportedObjectClass, item), "Type");
                    }
                }
            }
            if (item == null)
            {
                item = factory.StructuralObjectClass;
            }
            return(item);
        }
예제 #21
0
 private bool ADCentralAccessPolicyPreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
 {
     if (operation == ADFactory <T> .DirectoryOperation.Create)
     {
         IntPtr zero = IntPtr.Zero;
         int    num  = UnsafeNativeMethods.GenerateNewCAPID(out zero);
         if (num != 0 || !(IntPtr.Zero != zero))
         {
             throw new ADException(StringResources.CAPIDCreationFailure);
         }
         else
         {
             SecurityIdentifier securityIdentifier = new SecurityIdentifier(zero);
             UnsafeNativeMethods.LocalFree(zero);
             directoryObj["msAuthz-CentralAccessPolicyID"].Value = securityIdentifier;
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
예제 #22
0
 protected internal override string GenerateRDNPrefix(ADObjectFactory <ADObject> factory, ADParameterSet cmdletParameters, RenameADObjectParameterSet dynamicParameters, string oldDN)
 {
     return(oldDN.Substring(0, ADPathHelper.IndexOfFirstDelimiter(oldDN, '=', '\\')));
 }
예제 #23
0
        private bool ADObjectPreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
        {
            bool hasValue;

            if (operation != ADFactory <T> .DirectoryOperation.Update || !base.PropertyHasChange(ADObjectFactory <T> .ADObjectPropertyMap.ProtectedFromDeletion.PropertyName, instance, parameters, operation))
            {
                return(false);
            }
            else
            {
                bool?singleValueProperty = base.GetSingleValueProperty <bool?>(ADObjectFactory <T> .ADObjectPropertyMap.ProtectedFromDeletion.PropertyName, instance, parameters, operation);
                if (singleValueProperty.HasValue)
                {
                    bool?nullable = singleValueProperty;
                    if (!nullable.GetValueOrDefault())
                    {
                        hasValue = false;
                    }
                    else
                    {
                        hasValue = nullable.HasValue;
                    }
                    if (!hasValue)
                    {
                        return(ProtectedFromDeletionUtil.UnprotectFromAccidentalDeletion(directoryObj, base.CmdletSessionInfo));
                    }
                    else
                    {
                        return(ProtectedFromDeletionUtil.ProtectFromAccidentalDeletion(directoryObj, base.CmdletSessionInfo));
                    }
                }
                else
                {
                    return(false);
                }
            }
        }
예제 #24
0
        protected internal override string GenerateRDNPrefix(ADObjectFactory <ADObject> factory, ADParameterSet cmdletParameters, NewADObjectParameterSet dynamicParameters)
        {
            ADSessionInfo sessionInfo  = this.GetSessionInfo();
            ADSchemaUtil  aDSchemaUtil = new ADSchemaUtil(sessionInfo);
            string        rDNPrefix    = aDSchemaUtil.GetRDNPrefix(dynamicParameters.Type);

            if (rDNPrefix == null)
            {
                rDNPrefix = factory.RDNPrefix;
            }
            return(rDNPrefix);
        }
 internal override string GenerateObjectName(ADParameterSet parameters)
 {
     throw new NotSupportedException();
 }
예제 #26
0
 private bool ADReplicationSitePreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
 {
     if (ADFactory <T> .DirectoryOperation.Update == operation || operation == ADFactory <T> .DirectoryOperation.Create)
     {
         MappingTable <AttributeConverterEntry> item         = ADNtdsSiteSettingFactory <ADNtdsSiteSetting> .AttributeTable[base.ConnectedStore];
         MappingTable <AttributeConverterEntry> mappingTable = ADReplicationSiteFactory <T> .AttributeTable[base.ConnectedStore];
         ADTopologyUtil.RemoveChildObjectAttributes(directoryObj, mappingTable, item);
         return(true);
     }
     else
     {
         return(false);
     }
 }
예제 #27
0
        private bool ADClaimTypePreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
        {
            bool          classes       = true;
            StringBuilder stringBuilder = new StringBuilder();

            if (operation == ADFactory <T> .DirectoryOperation.Create || ADFactory <T> .DirectoryOperation.Update == operation)
            {
                bool switchParameterBooleanValue = parameters.GetSwitchParameterBooleanValue("SourceTransformPolicy");
                if (switchParameterBooleanValue)
                {
                    directoryObj.SetValue("msDS-ClaimSourceType", "TransformPolicy");
                    directoryObj.ForceRemove("msDS-ClaimAttributeSource");
                    directoryObj.ForceRemove("msDS-ClaimSource");
                }
                classes = classes & ADClaimTypeFactory <T> .VerifyClaimSourceAndAttributeExclusiveness(directoryObj, stringBuilder, operation);

                classes = classes & ADClaimTypeFactory <T> .VerifyClaimSourceAndPossibleValueExclusiveness(directoryObj, stringBuilder);

                classes = classes & ADClaimTypeFactory <T> .SetAndValidateClaimSourceType(directoryObj, stringBuilder);

                classes = classes & ADClaimTypeFactory <T> .VerifyRestrictValues(directoryObj, stringBuilder, base.CmdletSessionInfo, operation);

                if (directoryObj.Contains("msDS-ClaimValueType"))
                {
                    ADClaimValueType num = (ADClaimValueType)((long)Convert.ToInt32(directoryObj["msDS-ClaimValueType"].Value, CultureInfo.InvariantCulture));
                    classes = classes & ADCBACUtil.VerifyAndSetPossibleValues(directoryObj, num, stringBuilder);
                }
                classes = classes & ADClaimTypeFactory <T> .VerifyAppliesToClasses(directoryObj, stringBuilder, base.CmdletSessionInfo);

                if (classes)
                {
                    return(false);
                }
                else
                {
                    stringBuilder.AppendLine(StringResources.CTParameterValidationFailure);
                    throw new ADException(stringBuilder.ToString());
                }
            }
            else
            {
                return(false);
            }
        }
예제 #28
0
        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);
            }
        }
        private bool ADReplicationSiteLinkBridgePreCommitFSRoutine(ADFactory <T> .DirectoryOperation operation, T instance, ADParameterSet parameters, ADObject directoryObj)
        {
            string parentPath = ADPathModule.GetParentPath(directoryObj.DistinguishedName, null, ADPathFormat.X500);

            if ((!directoryObj.Contains("siteLinkList") || directoryObj["siteLinkList"].Count <= 1) && operation == ADFactory <T> .DirectoryOperation.Create)
            {
                object[] objArray = new object[4];
                objArray[0] = "SiteLinkBridge";
                objArray[1] = 2;
                objArray[2] = "SiteLinks";
                objArray[3] = "SiteLinksIncluded";
                throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.ADInvalidAttributeValueCount, objArray));
            }
            else
            {
                if (directoryObj.Contains("siteLinkList") && directoryObj["siteLinkList"].Count > 0)
                {
                    foreach (string item in directoryObj["siteLinkList"])
                    {
                        string str = ADPathModule.GetParentPath(item, null, ADPathFormat.X500);
                        if (string.Compare(str, parentPath, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            continue;
                        }
                        object[] distinguishedName = new object[2];
                        distinguishedName[0] = item;
                        distinguishedName[1] = directoryObj.DistinguishedName;
                        throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.SiteLinkAndSiteLinkBridgeDoNotShareSameTransportType, distinguishedName));
                    }
                }
                return(false);
            }
        }