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);
            }
        }
Beispiel #2
0
 internal override T GetExtendedObjectFromIdentity(T identityObj, string identityQueryPath, ICollection <string> propertiesToFetch, bool showDeleted)
 {
     if (base.CmdletSessionInfo != null)
     {
         MappingTable <AttributeConverterEntry> item         = ADNtdsSiteSettingFactory <ADNtdsSiteSetting> .AttributeTable[base.ConnectedStore];
         MappingTable <AttributeConverterEntry> mappingTable = ADReplicationSiteFactory <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 str = ADPathModule.MakePath(extendedObjectFromIdentity.DistinguishedName, "CN=NTDS Site Settings,", ADPathFormat.X500);
         try
         {
             ADTopologyUtil.ConstructAggregateObject <ADNtdsSiteSettingFactory <ADNtdsSiteSetting>, ADNtdsSiteSetting>(str, extendedObjectFromIdentity, identityQueryPath, childAttributes, showDeleted, base.CmdletSessionInfo);
         }
         catch (ADIdentityNotFoundException aDIdentityNotFoundException)
         {
             DebugLogger.LogInfo(this._debugCategory, string.Format("ADReplicationSiteFactory: Ntds-Site-Setting object not found for the site {0}, while constructing ADReplicationSite", extendedObjectFromIdentity.DistinguishedName));
         }
         return(extendedObjectFromIdentity);
     }
     else
     {
         throw new ArgumentNullException(StringResources.SessionRequired);
     }
 }
Beispiel #3
0
 internal static ADObjectSearcher DistinguishedNameIdentityResolver(object identityObject, string searchBase, CmdletSessionInfo cmdletSessionInfo, out bool useSearchFilter)
 {
     useSearchFilter = false;
     if (identityObject != null)
     {
         string str = identityObject as string;
         if (string.IsNullOrEmpty(str) || !ADPathModule.IsValidPath(str, ADPathFormat.X500) || !ADForestPartitionInfo.IsDNUnderPartition(cmdletSessionInfo.ADRootDSE, str, false))
         {
             ADObject aDObject = identityObject as ADObject;
             if (aDObject == null || string.IsNullOrEmpty(aDObject.DistinguishedName))
             {
                 return(null);
             }
             else
             {
                 return(IdentityResolverMethods.BuildDNBaseSearcher(aDObject.DistinguishedName, cmdletSessionInfo));
             }
         }
         else
         {
             return(IdentityResolverMethods.BuildDNBaseSearcher(str, cmdletSessionInfo));
         }
     }
     else
     {
         throw new ArgumentNullException("identityObject");
     }
 }
Beispiel #4
0
 internal static void ToCompatibleResourceTypes(string extendedAttribute, string[] directoryAttributes, ADEntity userObj, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo)
 {
     if (!directoryObj.Contains("msDS-ClaimValueType") || !directoryObj.Contains("msDS-ClaimIsValueSpaceRestricted"))
     {
         ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection(null);
         userObj.Add(extendedAttribute, aDPropertyValueCollection);
         return;
     }
     else
     {
         long           value            = (long)directoryObj["msDS-ClaimValueType"].Value;
         bool           flag             = directoryObj.Contains("msDS-ClaimPossibleValues");
         IADOPathNode   aDOPathNode      = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "msDS-ClaimValueType", value);
         IADOPathNode   aDOPathNode1     = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "msDS-IsPossibleValuesPresent", flag);
         IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2];
         aDOPathNodeArray[0] = aDOPathNode;
         aDOPathNodeArray[1] = aDOPathNode1;
         IADOPathNode aDOPathNode2 = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
         ADResourcePropertyValueTypeFactory <ADResourcePropertyValueType> aDResourcePropertyValueTypeFactory = new ADResourcePropertyValueTypeFactory <ADResourcePropertyValueType>();
         aDResourcePropertyValueTypeFactory.SetCmdletSessionInfo(cmdletSessionInfo);
         string str       = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Value Types,CN=Claims Configuration,CN=Services,", ADPathFormat.X500);
         int?   nullable  = null;
         int?   nullable1 = null;
         IEnumerable <ADResourcePropertyValueType> extendedObjectFromFilter = aDResourcePropertyValueTypeFactory.GetExtendedObjectFromFilter(aDOPathNode2, str, ADSearchScope.OneLevel, null, nullable, nullable1, false);
         List <string> strs = new List <string>();
         foreach (ADResourcePropertyValueType aDResourcePropertyValueType in extendedObjectFromFilter)
         {
             strs.Add(aDResourcePropertyValueType.Name);
         }
         userObj.Add(extendedAttribute, new ADPropertyValueCollection(strs));
         return;
     }
 }
Beispiel #5
0
        internal static IADOPathNode ToSearchFromResourcePropertyNameToDN(string extendedAttributeName, string[] directoryAttributes, IADOPathNode filterClause, CmdletSessionInfo cmdletSessionInfo)
        {
            string str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Claims Configuration,CN=Services,", ADPathFormat.X500);

            str = ADPathModule.MakePath(str, "CN=Resource Properties,", ADPathFormat.X500);
            return(SearchConverters.ToSearchFromADEntityToAttributeValue <ADResourcePropertyFactory <ADResourceProperty>, ADResourceProperty>(str, null, extendedAttributeName, directoryAttributes, filterClause, cmdletSessionInfo));
        }
Beispiel #6
0
        private static bool VerifySharesValuesWith(ADObject directoryObj, StringBuilder errorBuffer, ADObject resourcePropertyValueTypeObj, CmdletSessionInfo cmdletSessionInfo)
        {
            bool flag = false;

            if (directoryObj.Contains("msDS-ClaimSharesPossibleValuesWith") && resourcePropertyValueTypeObj != null)
            {
                ADClaimTypeFactory <ADClaimType> aDClaimTypeFactory = new ADClaimTypeFactory <ADClaimType>();
                aDClaimTypeFactory.SetCmdletSessionInfo(cmdletSessionInfo);
                ADClaimType aDClaimType = new ADClaimType();
                aDClaimType.Identity = directoryObj["msDS-ClaimSharesPossibleValuesWith"].Value as string;
                string str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Claims Configuration,CN=Services,", ADPathFormat.X500);
                str = ADPathModule.MakePath(str, "CN=Claim Types,", ADPathFormat.X500);
                ADObject extendedObjectFromIdentity = aDClaimTypeFactory.GetExtendedObjectFromIdentity(aDClaimType, str);
                if (!extendedObjectFromIdentity.Contains("CompatibleResourceTypes") || extendedObjectFromIdentity["CompatibleResourceTypes"].Value == null)
                {
                    flag = true;
                    errorBuffer.AppendLine(StringResources.ResourcePropertySharesValueWithValueTypeError);
                }
                else
                {
                    List <string> value = extendedObjectFromIdentity["CompatibleResourceTypes"].Value as List <string>;
                    if (!value.Contains(resourcePropertyValueTypeObj.Name))
                    {
                        flag = true;
                        errorBuffer.AppendLine(StringResources.ResourcePropertySharesValueWithValueTypeError);
                    }
                }
            }
            return(!flag);
        }
Beispiel #7
0
        internal static object FromNameToTopologyDN <F, O>(object entity, string extendedAttribute, CmdletSessionInfo cmdletSessionInfo)
            where F : ADFactory <O>, new()
            where O : ADEntity, new()
        {
            string str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Sites,", ADPathFormat.X500);

            return(AttributeConverters.GetAttributeValueFromObjectName <F, O>(entity, str, null, extendedAttribute, cmdletSessionInfo));
        }
Beispiel #8
0
        internal static IADOPathNode ToSearchFromTopologyObjectNameToDN <F, O>(string extendedAttributeName, string[] directoryAttributes, IADOPathNode filterClause, CmdletSessionInfo cmdletSessionInfo)
            where F : ADFactory <O>, new()
            where O : ADEntity, new()
        {
            string str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Sites,", ADPathFormat.X500);

            return(SearchConverters.ToSearchFromADEntityToAttributeValue <F, O>(str, null, extendedAttributeName, directoryAttributes, filterClause, cmdletSessionInfo));
        }
Beispiel #9
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);
        }
Beispiel #10
0
        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 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);
        }
Beispiel #12
0
 private string GetConnectionContainerPath()
 {
     if (this.queryPath != null)
     {
         return(this.queryPath);
     }
     else
     {
         return(ADPathModule.MakePath(this.GetRootDSE().ConfigurationNamingContext, "CN=Sites,", ADPathFormat.X500));
     }
 }
Beispiel #13
0
        internal static string[] GetClaimTypeName(ADClaimType[] claims, CmdletSessionInfo cmdletSessionInfo, string extendedAttribute)
        {
            List <string> strs = new List <string>();

            ADClaimType[] aDClaimTypeArray = claims;
            for (int i = 0; i < (int)aDClaimTypeArray.Length; i++)
            {
                ADClaimType aDClaimType = aDClaimTypeArray[i];
                string      str         = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Claims Configuration,CN=Services,", ADPathFormat.X500);
                str = ADPathModule.MakePath(str, "CN=Claim Types,", ADPathFormat.X500);
                string attributeValueFromObjectName = (string)AttributeConverters.GetAttributeValueFromObjectName <ADClaimTypeFactory <ADClaimType>, ADClaimType>(aDClaimType, str, "Name", extendedAttribute, cmdletSessionInfo);
                strs.Add(attributeValueFromObjectName);
            }
            return(strs.ToArray());
        }
Beispiel #14
0
        internal static string CreateISTPPath(ADInterSiteTransportProtocolType type, string ConfigurationNC)
        {
            string str;
            string str1 = ADPathModule.MakePath(ConfigurationNC, "CN=Inter-Site Transports,CN=Sites,", ADPathFormat.X500);

            if (type != ADInterSiteTransportProtocolType.SMTP)
            {
                str = "CN=IP,";
            }
            else
            {
                str = "CN=SMTP,";
            }
            return(ADPathModule.MakePath(str1, str, ADPathFormat.X500));
        }
Beispiel #15
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);
        }
Beispiel #16
0
        internal override T GetExtendedObjectFromDN(string distinguishedName, ICollection <string> propertiesToFetch, bool showDeleted)
        {
            string str = ADPathModule.MakePath(base.CmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Partitions", ADPathFormat.X500);

            if (ADPathModule.ComparePath(str, distinguishedName, ADPathFormat.X500))
            {
                return(this.GetExtendedForestObjectUsingCurrentSession(propertiesToFetch, showDeleted));
            }
            else
            {
                object[] objArray = new object[2];
                objArray[0] = str;
                objArray[1] = distinguishedName;
                throw new ADIdentityNotFoundException(string.Format(CultureInfo.CurrentCulture, StringResources.ConnectedToWrongForest, objArray));
            }
        }
Beispiel #17
0
        internal static void ToDirectoryFromSPCTNameToDN(string extendedAttribute, string[] directoryAttributes, ADPropertyValueCollection extendedData, ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo)
        {
            string str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Claims Configuration,CN=Services,", ADPathFormat.X500);

            str = ADPathModule.MakePath(str, "CN=Claim Types,", ADPathFormat.X500);
            try
            {
                AttributeConverters.ToDirectoryFromADEntityToAttributeValue <ADClaimTypeFactory <ADClaimType>, ADClaimType>(str, null, extendedAttribute, directoryAttributes, extendedData, directoryObj, cmdletSessionInfo);
            }
            catch (ADIdentityResolutionException aDIdentityResolutionException1)
            {
                ADIdentityResolutionException aDIdentityResolutionException = aDIdentityResolutionException1;
                object[] message = new object[1];
                message[0] = aDIdentityResolutionException.Message;
                throw new ADIdentityResolutionException(string.Format(CultureInfo.CurrentCulture, StringResources.SharesValueWithIdentityError, message), aDIdentityResolutionException);
            }
        }
Beispiel #18
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);
        }
 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);
     }
 }
        private static bool IsValidPartitionDN(ADRootDSE rootDSE, string partitionDN, bool refreshForestPartitionList)
        {
            bool flag;

            if (rootDSE != null)
            {
                if (partitionDN != null)
                {
                    if (rootDSE.SessionInfo == null || !rootDSE.SessionInfo.ConnectedToGC || !partitionDN.Equals(string.Empty))
                    {
                        IEnumerable <string> validPartitionList = ADForestPartitionInfo.GetValidPartitionList(rootDSE, refreshForestPartitionList);
                        IEnumerator <string> enumerator         = validPartitionList.GetEnumerator();
                        using (enumerator)
                        {
                            while (enumerator.MoveNext())
                            {
                                string current = enumerator.Current;
                                if (!ADPathModule.ComparePath(partitionDN, current, ADPathFormat.X500))
                                {
                                    continue;
                                }
                                flag = true;
                                return(flag);
                            }
                            return(false);
                        }
                        return(flag);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    throw new ArgumentNullException("partitionDN");
                }
            }
            else
            {
                throw new ArgumentNullException("rootDSE");
            }
        }
Beispiel #21
0
        internal static string GetCurrentDriveLocation(SessionState sessionState, ADSessionInfo sessionInfo)
        {
            string      str     = null;
            ADDriveInfo current = sessionState.Drive.Current as ADDriveInfo;

            if (current != null)
            {
                string currentLocation = current.CurrentLocation;
                str = ADPathModule.MakePath(current.RootWithoutAbsolutePathToken, currentLocation, current.FormatType);
                if (current.FormatType == ADPathFormat.Canonical && str != string.Empty)
                {
                    if (sessionInfo.Server != null)
                    {
                        //TODO: Review sessionInfo.Server;
                    }
                    str = ADPathModule.ConvertPath(sessionInfo, str, ADPathFormat.Canonical, ADPathFormat.X500);
                }
            }
            return(str);
        }
Beispiel #22
0
        private bool ADSetADClaimTransformLinkBeginCSRoutine()
        {
            ADClaimTransformPolicy item     = this._cmdletParameters["Policy"] as ADClaimTransformPolicy;
            ADTrustRole?           nullable = (ADTrustRole?)(this._cmdletParameters["TrustRole"] as ADTrustRole?);
            string value = null;

            if (item != null)
            {
                if (!item.IsSearchResult)
                {
                    ADClaimTransformPolicyFactory <ADClaimTransformPolicy> aDClaimTransformPolicyFactory = new ADClaimTransformPolicyFactory <ADClaimTransformPolicy>();
                    CmdletSessionInfo cmdletSessionInfo = base.GetCmdletSessionInfo();
                    aDClaimTransformPolicyFactory.SetCmdletSessionInfo(cmdletSessionInfo);
                    string   str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Claims Transformation Policies,CN=Claims Configuration,CN=Services,", ADPathFormat.X500);
                    ADObject directoryObjectFromIdentity = aDClaimTransformPolicyFactory.GetDirectoryObjectFromIdentity(item, str);
                    value = directoryObjectFromIdentity["distinguishedName"].Value as string;
                }
                else
                {
                    value = item["distinguishedName"].Value as string;
                }
            }
            ADTrustRole aDTrustRole = nullable.Value;

            switch (aDTrustRole)
            {
            case ADTrustRole.Trusted:
                {
                    this._cmdletParameters["TrustedPolicy"] = value;
                    break;
                }

            case ADTrustRole.Trusting:
            {
                this._cmdletParameters["TrustingPolicy"] = value;
                break;
            }
            }
            this._cmdletParameters.RemoveParameter("Policy");
            return(true);
        }
Beispiel #23
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));
            }
        }
Beispiel #24
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         = ADNtdsSiteSettingFactory <ADNtdsSiteSetting> .AttributeTable[base.ConnectedStore];
         MappingTable <AttributeConverterEntry> mappingTable = ADReplicationSiteFactory <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);
         ADNtdsSiteSettingFactory <ADNtdsSiteSetting> aDNtdsSiteSettingFactory = new ADNtdsSiteSettingFactory <ADNtdsSiteSetting>();
         aDNtdsSiteSettingFactory.SetCmdletSessionInfo(base.CmdletSessionInfo);
         IEnumerable <ADNtdsSiteSetting>        aDNtdsSiteSettings = aDNtdsSiteSettingFactory.GetExtendedObjectFromFilter(aDNtdsSiteSettingFactory.StructuralObjectFilter, searchBase, searchScope, childAttributes, resultSetSize, pageSize, showDeleted);
         Dictionary <string, ADNtdsSiteSetting> strs = new Dictionary <string, ADNtdsSiteSetting>();
         foreach (ADNtdsSiteSetting aDNtdsSiteSetting in aDNtdsSiteSettings)
         {
             strs.Add(aDNtdsSiteSetting.DistinguishedName, aDNtdsSiteSetting);
         }
         List <T> ts = new List <T>();
         foreach (T t in extendedObjectFromFilter)
         {
             string str = ADPathModule.MakePath(t.DistinguishedName, "CN=NTDS Site Settings,", ADPathFormat.X500);
             if (strs.ContainsKey(str))
             {
                 ADNtdsSiteSetting item1 = strs[str];
                 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);
     }
 }
Beispiel #25
0
        private static bool VerifyResourcePropertyValueType(ADEntity directoryObj, CmdletSessionInfo cmdletSessionInfo, out ADObject resourcePropertyValueTypeObj, StringBuilder errorBuffer)
        {
            bool flag = false;

            resourcePropertyValueTypeObj = null;
            if (directoryObj.Contains("msDS-ValueTypeReference"))
            {
                string value = directoryObj["msDS-ValueTypeReference"].Value as string;
                ADResourcePropertyValueTypeFactory <ADResourcePropertyValueType> aDResourcePropertyValueTypeFactory = new ADResourcePropertyValueTypeFactory <ADResourcePropertyValueType>();
                aDResourcePropertyValueTypeFactory.SetCmdletSessionInfo(cmdletSessionInfo);
                ADResourcePropertyValueType aDResourcePropertyValueType = new ADResourcePropertyValueType();
                aDResourcePropertyValueType.Identity = value;
                string str = ADPathModule.MakePath(cmdletSessionInfo.ADRootDSE.ConfigurationNamingContext, "CN=Value Types,CN=Claims Configuration,CN=Services,", ADPathFormat.X500);
                resourcePropertyValueTypeObj = aDResourcePropertyValueTypeFactory.GetExtendedObjectFromIdentity(aDResourcePropertyValueType, str);
            }
            else
            {
                flag = true;
                errorBuffer.AppendLine(StringResources.RCTNoResourcePropertyValueTypeError);
            }
            return(!flag);
        }
        internal static string ExtractPartitionInfo(ADRootDSE rootDSE, string objectDN, bool refreshForestPartitionList)
        {
            string str = null;

            if (rootDSE != null)
            {
                if (objectDN != null)
                {
                    if (rootDSE.SessionInfo == null || !rootDSE.SessionInfo.ConnectedToGC || !objectDN.Equals(string.Empty))
                    {
                        IEnumerable <string> validPartitionList = ADForestPartitionInfo.GetValidPartitionList(rootDSE, refreshForestPartitionList);
                        int length = -1;
                        foreach (string str1 in validPartitionList)
                        {
                            if (str1.Length <= length || !ADPathModule.IsChildPath(objectDN, str1, true, ADPathFormat.X500))
                            {
                                continue;
                            }
                            length = str1.Length;
                            str    = str1;
                        }
                        return(str);
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
                else
                {
                    throw new ArgumentNullException("objectDN");
                }
            }
            else
            {
                throw new ArgumentNullException("rootDSE");
            }
        }
        internal static bool IsDNUnderPartition(ADRootDSE rootDSE, string objectDN, bool refreshForestPartitionList)
        {
            bool flag;

            if (rootDSE != null)
            {
                if (!string.IsNullOrEmpty(objectDN))
                {
                    IEnumerable <string> validPartitionList = ADForestPartitionInfo.GetValidPartitionList(rootDSE, refreshForestPartitionList);
                    IEnumerator <string> enumerator         = validPartitionList.GetEnumerator();
                    using (enumerator)
                    {
                        while (enumerator.MoveNext())
                        {
                            string current = enumerator.Current;
                            if (!ADPathModule.IsChildPath(objectDN, current, true, ADPathFormat.X500))
                            {
                                continue;
                            }
                            flag = true;
                            return(flag);
                        }
                        return(false);
                    }
                    return(flag);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                throw new ArgumentNullException("rootDSE");
            }
        }
Beispiel #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);
            }
        }
Beispiel #29
0
        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);
        }
Beispiel #30
0
 protected internal override string GetDefaultCreationPathBase()
 {
     return(ADPathModule.MakePath(this.GetRootDSE().ConfigurationNamingContext, "CN=Sites,", ADPathFormat.X500));
 }