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);
            }
        }
예제 #2
0
 internal override T GetExtendedObjectFromIdentity(T identityObj, string identityQueryPath, ICollection <string> propertiesToFetch, bool showDeleted)
 {
     if (base.CmdletSessionInfo != null)
     {
         MappingTable <AttributeConverterEntry> item         = ADNtdsSettingFactory <ADNtdsSetting> .AttributeTable[base.ConnectedStore];
         MappingTable <AttributeConverterEntry> mappingTable = ADReplicationConnectionFactory <T> .AttributeTable[base.ConnectedStore];
         ICollection <string> parentAttributes = ADTopologyUtil.GetParentAttributes(mappingTable, item, propertiesToFetch);
         ICollection <string> childAttributes  = ADTopologyUtil.GetChildAttributes(mappingTable, item, propertiesToFetch);
         T      extendedObjectFromIdentity     = base.GetExtendedObjectFromIdentity(identityObj, identityQueryPath, parentAttributes, showDeleted);
         string parentPath = ADPathModule.GetParentPath(extendedObjectFromIdentity.DistinguishedName, null, ADPathFormat.X500);
         try
         {
             ADTopologyUtil.ConstructAggregateObject <ADNtdsSettingFactory <ADNtdsSetting>, ADNtdsSetting>(parentPath, extendedObjectFromIdentity, identityQueryPath, childAttributes, showDeleted, base.CmdletSessionInfo);
         }
         catch (ADIdentityNotFoundException aDIdentityNotFoundException)
         {
             DebugLogger.LogInfo(this._debugCategory, string.Format("ADReplicationConnectionFactory: Ntds-Setting object not found for the connection {0}, while constructing ADReplicationConnection", extendedObjectFromIdentity.DistinguishedName));
         }
         return(extendedObjectFromIdentity);
     }
     else
     {
         throw new ArgumentNullException(StringResources.SessionRequired);
     }
 }
예제 #3
0
        internal static void ToExtendedSourceNameFromDN(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo)
        {
            string value = (string)directoryObj[directoryAttributes[0]].Value;

            value = ADPathModule.GetParentPath(value, null, ADPathFormat.X500);
            value = ADPathModule.GetParentPath(value, null, ADPathFormat.X500);
            ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(value);

            userObj.Add(extendedAttribute, aDPropertyValueCollection);
        }
예제 #4
0
        private bool ADRenameCmdletBaseProcessCSRoutine()
        {
            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._cmdletParameters["Partition"] as string;

            if (defaultPartitionPath == null)
            {
                defaultPartitionPath = this.GetDefaultPartitionPath();
                if (defaultPartitionPath == null && !item.IsSearchResult)
                {
                    object[] objArray = new object[1];
                    objArray[0] = "Partition";
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ParameterRequired, objArray));
                }
            }
            ADObject directoryObjectFromIdentity = this._factory.GetDirectoryObjectFromIdentity(item, defaultPartitionPath);

            using (ADActiveObject aDActiveObject = new ADActiveObject(cmdletSessionInfo.ADSessionInfo, directoryObjectFromIdentity))
            {
                string str = this.GenerateNewRDN(this._factory, this._cmdletParameters, this._cmdletParameters, directoryObjectFromIdentity.DistinguishedName);
                if (base.ShouldProcessOverride(directoryObjectFromIdentity.DistinguishedName, "Rename"))
                {
                    O o = default(O);
                    if (this._factory.PreCommitProcesing(ADFactory <O> .DirectoryOperation.Rename, o, this._cmdletParameters, directoryObjectFromIdentity))
                    {
                        aDActiveObject.Update();
                    }
                    aDActiveObject.Rename(str);
                    O o1 = default(O);
                    this._factory.PostCommitProcesing(ADFactory <O> .DirectoryOperation.Rename, o1, this._cmdletParameters, directoryObjectFromIdentity);
                    if (this._cmdletParameters.GetSwitchParameterBooleanValue("PassThru"))
                    {
                        string value                = directoryObjectFromIdentity["distinguishedName"].Value as string;
                        string parentPath           = ADPathModule.GetParentPath(value, null, ADPathFormat.X500);
                        string str1                 = ADPathModule.MakePath(parentPath, str, ADPathFormat.X500);
                        O      extendedObjectFromDN = this._factory.GetExtendedObjectFromDN(str1);
                        base.WriteObject(extendedObjectFromDN);
                    }
                    return(true);
                }
                else
                {
                    flag = false;
                }
            }
            return(flag);
        }
예제 #5
0
        internal static void ToExtendedFromDNToISTPEnum(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo)
        {
            string value = (string)directoryObj[directoryAttributes[0]].Value;

            value = ADPathModule.GetParentPath(value, null, ADPathFormat.X500);
            string childName = ADPathModule.GetChildName(value, ADPathFormat.X500);
            ADInterSiteTransportProtocolType aDInterSiteTransportProtocolType = ADInterSiteTransportProtocolType.IP;

            if (string.Compare("CN=IP", childName, StringComparison.OrdinalIgnoreCase) != 0)
            {
                aDInterSiteTransportProtocolType = ADInterSiteTransportProtocolType.SMTP;
            }
            ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection((object)aDInterSiteTransportProtocolType);

            userObj.Add(extendedAttribute, aDPropertyValueCollection);
        }
예제 #6
0
        internal static bool?IsProtectedFromDeletion(ADObject directoryObj, CmdletSessionInfo cmdletSessionInfo)
        {
            bool flag;

            ProtectedFromDeletionUtil.AddObjectToCache(directoryObj, cmdletSessionInfo);
            if (!directoryObj.Contains("nTSecurityDescriptor") || directoryObj["nTSecurityDescriptor"].Value == null)
            {
                bool?nullable = null;
                return(nullable);
            }
            else
            {
                bool flag1 = ProtectedFromDeletionUtil.EveryoneDeniedDeleteAndDeleteTree(directoryObj);
                if (!Utils.IsNamingContext(directoryObj) && !Utils.IsDeleted(directoryObj))
                {
                    string   parentPath   = ADPathModule.GetParentPath(directoryObj.DistinguishedName, null, ADPathFormat.X500);
                    ADObject cachedObject = ProtectedFromDeletionUtil.GetCachedObject(parentPath, ProtectedFromDeletionUtil.AttributesToFetchOnParent, cmdletSessionInfo);
                    if (cachedObject != null)
                    {
                        if (!cachedObject.Contains("nTSecurityDescriptor") || cachedObject["nTSecurityDescriptor"].Value == null)
                        {
                            bool?nullable1 = null;
                            return(nullable1);
                        }
                        else
                        {
                            if (!ProtectedFromDeletionUtil.EveryoneDeniedDeleteChild(cachedObject))
                            {
                                flag = false;
                            }
                            else
                            {
                                flag = flag1;
                            }
                            return(new bool?(flag));
                        }
                    }
                }
                return(new bool?(flag1));
            }
        }
예제 #7
0
 internal override IEnumerable <T> GetExtendedObjectFromFilter(IADOPathNode filter, string searchBase, ADSearchScope searchScope, ICollection <string> propertiesToFetch, int?resultSetSize, int?pageSize, bool showDeleted)
 {
     if (base.CmdletSessionInfo != null)
     {
         MappingTable <AttributeConverterEntry> item         = ADNtdsSettingFactory <ADNtdsSetting> .AttributeTable[base.ConnectedStore];
         MappingTable <AttributeConverterEntry> mappingTable = ADReplicationConnectionFactory <T> .AttributeTable[base.ConnectedStore];
         ICollection <string> parentAttributes = ADTopologyUtil.GetParentAttributes(mappingTable, item, propertiesToFetch);
         ICollection <string> childAttributes  = ADTopologyUtil.GetChildAttributes(mappingTable, item, propertiesToFetch);
         if (!parentAttributes.Contains("*"))
         {
             parentAttributes.Add("*");
         }
         IEnumerable <T> extendedObjectFromFilter = base.GetExtendedObjectFromFilter(this.StructuralObjectFilter, searchBase, searchScope, parentAttributes, resultSetSize, pageSize, showDeleted);
         ADNtdsSettingFactory <ADNtdsSetting> aDNtdsSettingFactory = new ADNtdsSettingFactory <ADNtdsSetting>();
         aDNtdsSettingFactory.SetCmdletSessionInfo(base.CmdletSessionInfo);
         IEnumerable <ADNtdsSetting>        aDNtdsSettings = aDNtdsSettingFactory.GetExtendedObjectFromFilter(aDNtdsSettingFactory.StructuralObjectFilter, searchBase, searchScope, childAttributes, resultSetSize, pageSize, showDeleted);
         Dictionary <string, ADNtdsSetting> strs           = new Dictionary <string, ADNtdsSetting>();
         foreach (ADNtdsSetting aDNtdsSetting in aDNtdsSettings)
         {
             strs.Add(aDNtdsSetting.DistinguishedName, aDNtdsSetting);
         }
         List <T> ts = new List <T>();
         foreach (T t in extendedObjectFromFilter)
         {
             string parentPath = ADPathModule.GetParentPath(t.DistinguishedName, null, ADPathFormat.X500);
             if (strs.ContainsKey(parentPath))
             {
                 ADNtdsSetting item1 = strs[parentPath];
                 ADTopologyUtil.MergeADObjectProperties(t, item1);
             }
             ts.Add(t);
         }
         IEnumerable <T> ts1 = this.ApplyClientSideFilter(ts);
         return(ADTopologyUtil.RemoveExtraPropertiesFromADAggregateObject <T>(mappingTable, item, propertiesToFetch, ts1));
     }
     else
     {
         throw new ArgumentNullException(StringResources.SessionRequired);
     }
 }
예제 #8
0
        internal static bool ProtectFromAccidentalDeletion(ADObject directoryObj, CmdletSessionInfo cmdletSessionInfo)
        {
            ADObject cachedObject;
            string   value = directoryObj["distinguishedName"].Value as string;

            if (!directoryObj.Contains("nTSecurityDescriptor") || !directoryObj.Contains("sdRightsEffective"))
            {
                cachedObject = ProtectedFromDeletionUtil.GetCachedObject(value, ProtectedFromDeletionUtil.AttributesToFetchOnObject, cmdletSessionInfo);
            }
            else
            {
                cachedObject = directoryObj;
                ProtectedFromDeletionUtil.AddObjectToCache(directoryObj, cmdletSessionInfo);
            }
            if (cachedObject == null || !cachedObject.Contains("nTSecurityDescriptor") || cachedObject["nTSecurityDescriptor"].Value == null)
            {
                object[] objArray = new object[1];
                objArray[0] = directoryObj["distinguishedName"].Value;
                throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.InsufficientPermissionsToProtectObject, objArray));
            }
            else
            {
                if (ProtectedFromDeletionUtil.EveryoneDeniedDeleteAndDeleteTree(cachedObject) || Utils.HasFlagsSet((int)cachedObject["sdRightsEffective"].Value, 4))
                {
                    if (!Utils.IsNamingContext(cachedObject) && !Utils.IsDeleted(cachedObject))
                    {
                        string   parentPath = ADPathModule.GetParentPath(value, null, ADPathFormat.X500);
                        ADObject aDObject   = ProtectedFromDeletionUtil.GetCachedObject(parentPath, ProtectedFromDeletionUtil.AttributesToFetchOnParent, cmdletSessionInfo);
                        if (aDObject != null && !ProtectedFromDeletionUtil.EveryoneDeniedDeleteChild(aDObject))
                        {
                            if (Utils.HasFlagsSet((int)aDObject["sdRightsEffective"].Value, 4))
                            {
                                ActiveDirectorySecurity activeDirectorySecurity = (ActiveDirectorySecurity)aDObject["nTSecurityDescriptor"].Value;
                                activeDirectorySecurity.AddAccessRule(ProtectedFromDeletionUtil.ACEConstants.DeleteChildAccessRule);
                                using (ADActiveObject aDActiveObject = new ADActiveObject(cmdletSessionInfo.ADSessionInfo, aDObject))
                                {
                                    aDObject.TrackChanges = true;
                                    aDObject["nTSecurityDescriptor"].Value = activeDirectorySecurity;
                                    aDActiveObject.Update();
                                }
                            }
                            else
                            {
                                object[] value1 = new object[2];
                                value1[0] = directoryObj["distinguishedName"].Value;
                                value1[1] = aDObject["distinguishedName"].Value;
                                throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.InsufficientPermissionsToProtectObjectParent, value1));
                            }
                        }
                    }
                    ActiveDirectorySecurity activeDirectorySecurity1 = (ActiveDirectorySecurity)cachedObject["nTSecurityDescriptor"].Value;
                    if (ProtectedFromDeletionUtil.EveryoneDeniedDeleteAndDeleteTree(cachedObject))
                    {
                        return(false);
                    }
                    else
                    {
                        activeDirectorySecurity1.AddAccessRule(ProtectedFromDeletionUtil.ACEConstants.DeleteAndDeleteTreeAccessRule);
                        if (!directoryObj.Contains("nTSecurityDescriptor"))
                        {
                            directoryObj.Add("nTSecurityDescriptor", activeDirectorySecurity1);
                        }
                        else
                        {
                            directoryObj["nTSecurityDescriptor"].Value = activeDirectorySecurity1;
                        }
                        return(true);
                    }
                }
                else
                {
                    object[] objArray1 = new object[1];
                    objArray1[0] = directoryObj["distinguishedName"].Value;
                    throw new ADException(string.Format(CultureInfo.CurrentCulture, StringResources.InsufficientPermissionsToProtectObject, objArray1));
                }
            }
        }