コード例 #1
0
ファイル: ProviderUtils.cs プロジェクト: nickchal/pash
		internal static string GetCurrentPartitionPath(SessionState sessionState)
		{
			ADRootDSE rootDSE;
			string str = null;
			ADDriveInfo current = sessionState.Drive.Current as ADDriveInfo;
			if (current != null)
			{
				using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(current.SessionInfo))
				{
					rootDSE = aDObjectSearcher.GetRootDSE();
					rootDSE.SessionInfo = current.SessionInfo;
				}
				string currentDriveLocation = ProviderUtils.GetCurrentDriveLocation(sessionState, current.SessionInfo);
				if (currentDriveLocation != string.Empty)
				{
					try
					{
						str = ADForestPartitionInfo.ExtractAndValidatePartitionInfo(rootDSE, currentDriveLocation);
					}
					catch (ArgumentException argumentException1)
					{
						ArgumentException argumentException = argumentException1;
						object[] objArray = new object[1];
						objArray[0] = currentDriveLocation;
						throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ProviderUtilInvalidDrivePath, objArray), argumentException);
					}
				}
				else
				{
					return string.Empty;
				}
			}
			return str;
		}
コード例 #2
0
ファイル: ADSchema.cs プロジェクト: nickchal/pash
		private void AddSchemaClassObjects(ADObjectSearcher searcher, ADSchema adSchema)
		{
			searcher.SchemaTranslation = false;
			ADRootDSE rootDSE = searcher.GetRootDSE();
			searcher.SearchRoot = rootDSE.SchemaNamingContext;
			IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "classSchema");
			IADOPathNode aDOPathNode1 = ADOPathUtil.CreateFilterClause(ADOperator.NotLike, "isDefunct", "*");
			IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2];
			aDOPathNodeArray[0] = aDOPathNode;
			aDOPathNodeArray[1] = aDOPathNode1;
			searcher.Filter = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
			searcher.Scope = ADSearchScope.Subtree;
			searcher.PageSize = 0x100;
			searcher.Properties.Clear();
			searcher.Properties.Add("lDAPDisplayName");
			searcher.Properties.Add("subClassOf");
			searcher.Properties.Add("systemMayContain");
			searcher.Properties.Add("mayContain");
			searcher.Properties.Add("mustContain");
			searcher.Properties.Add("systemMustContain");
			searcher.Properties.Add("auxiliaryClass");
			searcher.Properties.Add("systemAuxiliaryClass");
			IEnumerable<ADObject> aDObjects = searcher.FindAll();
			foreach (ADObject aDObject in aDObjects)
			{
				if (!aDObject.Contains("lDAPDisplayName") || aDObject["lDAPDisplayName"].Value == null)
				{
					continue;
				}
				adSchema._schemaClasses.Add((string)aDObject["lDAPDisplayName"].Value, aDObject);
				adSchema._schemaClassesDnHash.Add((string)aDObject["distinguishedName"].Value, (string)aDObject["lDAPDisplayName"].Value);
			}
		}
コード例 #3
0
ファイル: SearchUtility.cs プロジェクト: nickchal/pash
		internal static ADObjectSearcher BuildSearcher(ADSessionInfo session, string searchRoot, ADSearchScope searchScope, bool showDeleted)
		{
			ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(session);
			aDObjectSearcher.PageSize = 0x100;
			aDObjectSearcher.SearchRoot = searchRoot;
			aDObjectSearcher.Scope = searchScope;
			if (showDeleted)
			{
				aDObjectSearcher.ShowDeleted = true;
				aDObjectSearcher.ShowDeactivatedLink = true;
			}
			return aDObjectSearcher;
		}
コード例 #4
0
        private void ReadConstructedSchema(ADObjectSearcher searcher, ADSchema adSchema)
        {
            searcher.SchemaTranslation = false;
            ADRootDSE rootDSE = searcher.GetRootDSE();

            searcher.SearchRoot = rootDSE.SubSchemaSubEntry;
            searcher.Filter     = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
            searcher.Scope      = ADSearchScope.Base;
            searcher.Properties.Clear();
            searcher.Properties.Add("extendedAttributeInfo");
            searcher.Properties.Add("attributeTypes");
            ADObject aDObject = searcher.FindOne();
            int      success  = SchemaConstants.AttributeTypesRegex.GroupNumberFromName(SchemaConstants.NameGroup);
            int      num      = SchemaConstants.AttributeTypesRegex.GroupNumberFromName(SchemaConstants.SyntaxGroup);
            int      num1     = SchemaConstants.AttributeTypesRegex.GroupNumberFromName(SchemaConstants.SingleValueGroup);

            adSchema._schemaProperties = new Dictionary <string, ADSchemaAttribute>(1, StringComparer.OrdinalIgnoreCase);
            foreach (string item in aDObject["attributeTypes"])
            {
                Match match = SchemaConstants.AttributeTypesRegex.Match(item);
                if (match != null)
                {
                    if (!match.Groups[success].Success)
                    {
                        DebugLogger.LogError("adschema", string.Format("AttributeType {0} no match on Name", item));
                    }
                    if (!match.Groups[num].Success)
                    {
                        DebugLogger.LogError("adschema", string.Format("AttributeType {0} no match on Syntax", item));
                    }
                    adSchema._schemaProperties.Add(match.Groups[success].Value, new ADSchemaAttribute(ADSyntax.OIDToSyntax(match.Groups[num].Value), match.Groups[num1].Success, false));
                }
                else
                {
                    DebugLogger.LogError("adschema", string.Format("unable to match AttributeType {0}", item));
                    throw new ADException();
                }
            }
            success = SchemaConstants.ExtendedAttrInfoRegex.GroupNumberFromName(SchemaConstants.NameGroup);
            int num2 = SchemaConstants.ExtendedAttrInfoRegex.GroupNumberFromName(SchemaConstants.SystemOnlyGroup);

            foreach (string str in aDObject["extendedAttributeInfo"])
            {
                Match match1 = SchemaConstants.ExtendedAttrInfoRegex.Match(str);
                adSchema._schemaProperties[match1.Groups[success].Value].IsSystemOnly = match1.Groups[num2].Success;
            }
        }
コード例 #5
0
        private void ReadObjectSchema(ADObjectSearcher searcher, ADSchema adSchema)
        {
            searcher.SchemaTranslation = false;
            ADRootDSE rootDSE = searcher.GetRootDSE();

            searcher.SearchRoot = rootDSE.SchemaNamingContext;
            IADOPathNode[] aDOPathNodeArray = new IADOPathNode[3];
            aDOPathNodeArray[0] = ADOPathUtil.CreateNotClause(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "isDefunct", true));
            aDOPathNodeArray[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "attributeSchema");
            IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[3];
            aDOPathNodeArray1[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "attributeSyntax", SchemaConstants.SidAttributeSyntax);
            aDOPathNodeArray1[1] = ADOPathUtil.CreateFilterClause(ADOperator.Like, "linkID", "*");
            aDOPathNodeArray1[2] = ADOPathUtil.CreateFilterClause(ADOperator.Band, "systemFlags", SchemaConstants.systemFlagsConstructedBitMask);
            aDOPathNodeArray[2]  = ADOPathUtil.CreateOrClause(aDOPathNodeArray1);
            searcher.Filter      = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
            searcher.Scope       = ADSearchScope.Subtree;
            searcher.PageSize    = 0x100;
            searcher.Properties.Clear();
            searcher.Properties.Add("lDAPDisplayName");
            searcher.Properties.Add("linkID");
            searcher.Properties.Add("systemFlags");
            searcher.Properties.Add("attributeSyntax");
            IEnumerable <ADObject> aDObjects = searcher.FindAll();

            foreach (ADObject nullable in aDObjects)
            {
                if (adSchema._schemaProperties.ContainsKey((string)nullable["lDAPDisplayName"].Value))
                {
                    if (nullable.Contains("linkID"))
                    {
                        adSchema._schemaProperties[(string)nullable["lDAPDisplayName"].Value].LinkID = new int?(int.Parse(nullable["linkID"].Value as string, NumberFormatInfo.InvariantInfo));
                    }
                    if (nullable.Contains("systemFlags") && (long)0 != (ulong.Parse(nullable["systemFlags"].Value as string, NumberFormatInfo.InvariantInfo) & SchemaConstants.systemFlagsConstructedBitMask))
                    {
                        adSchema._schemaProperties[(string)nullable["lDAPDisplayName"].Value].IsConstructed = true;
                    }
                    if (!nullable.Contains("attributeSyntax") || string.Compare(nullable["attributeSyntax"].Value as string, SchemaConstants.SidAttributeSyntax, true) != 0)
                    {
                        continue;
                    }
                    adSchema._schemaProperties[(string)nullable["lDAPDisplayName"].Value].Syntax = ADAttributeSyntax.Sid;
                }
            }
        }
コード例 #6
0
ファイル: ADFactoryUtil.cs プロジェクト: nickchal/pash
		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;
		}
コード例 #7
0
 private void PopulateSchemaClasses()
 {
     if (this._schemaClasses == null)
     {
         ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(this._sessionInfo);
         {
             ADRootDSE rootDSE = aDObjectSearcher.GetRootDSE();
             this._subSchemaDN = rootDSE.SubSchemaSubEntry;
             if (rootDSE.ServerType == ADServerType.ADDS && this._sessionInfo.ConnectedToGC)
             {
                 this._sessionInfo.SetEffectivePort(LdapConstants.LDAP_PORT);
                 aDObjectSearcher.Dispose();
                 aDObjectSearcher = new ADObjectSearcher(this._sessionInfo);
             }
             this._schemaClasses       = new Dictionary <string, ADObject>(1, StringComparer.OrdinalIgnoreCase);
             this._schemaClassesDnHash = new Dictionary <string, string>(1, StringComparer.OrdinalIgnoreCase);
             this.AddSchemaClassObjects(aDObjectSearcher, this);
         }
         aDObjectSearcher.Dispose();
         lock (ADSchema._schemaTableLock)
         {
             ADSchema aDSchema = null;
             lock (ADSchema._schemaTableLock)
             {
                 ADSchema._schemaTable.TryGetValue(this._subSchemaDN, out aDSchema);
                 if (aDSchema != null)
                 {
                     aDSchema._schemaClasses       = this._schemaClasses;
                     aDSchema._schemaClassesDnHash = this._schemaClassesDnHash;
                 }
             }
         }
         return;
     }
     else
     {
         return;
     }
 }
コード例 #8
0
        private HashSet <string> GetUserSubClasses(ADObjectSearcher searcher, ADRootDSE rootDSE)
        {
            HashSet <string> strs = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            searcher.SearchRoot = rootDSE.SchemaNamingContext;
            searcher.Properties.Add("lDAPDisplayName");
            string       str          = string.Concat("CN=Person,", rootDSE.SchemaNamingContext);
            IADOPathNode aDOPathNode  = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "classSchema");
            IADOPathNode aDOPathNode1 = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "subClassOf", "user");
            IADOPathNode aDOPathNode2 = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "defaultObjectCategory", str);

            IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2];
            aDOPathNodeArray[0] = aDOPathNode;
            IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[2];
            aDOPathNodeArray1[0] = aDOPathNode1;
            aDOPathNodeArray1[1] = aDOPathNode2;
            aDOPathNodeArray[1]  = ADOPathUtil.CreateAndClause(aDOPathNodeArray1);
            IADOPathNode aDOPathNode3 = ADOPathUtil.CreateAndClause(aDOPathNodeArray);

            searcher.Filter = aDOPathNode3;
            IEnumerable <ADObject> aDObjects = searcher.FindAll();

            foreach (ADObject aDObject in aDObjects)
            {
                var ldapDisplayName = aDObject["lDAPDisplayName"];
                if (ldapDisplayName != null)
                {
                    if (ldapDisplayName.Count > 0)
                    {
                        strs.Add((string)ldapDisplayName[0]);
                    }
                }
            }
            strs.Add("user");
            return(strs);
        }
コード例 #9
0
        private void AddSchemaClassObjects(ADObjectSearcher searcher, ADSchema adSchema)
        {
            searcher.SchemaTranslation = false;
            ADRootDSE rootDSE = searcher.GetRootDSE();

            searcher.SearchRoot = rootDSE.SchemaNamingContext;
            IADOPathNode aDOPathNode  = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "classSchema");
            IADOPathNode aDOPathNode1 = ADOPathUtil.CreateFilterClause(ADOperator.NotLike, "isDefunct", "*");

            IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2];
            aDOPathNodeArray[0] = aDOPathNode;
            aDOPathNodeArray[1] = aDOPathNode1;
            searcher.Filter     = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
            searcher.Scope      = ADSearchScope.Subtree;
            searcher.PageSize   = 0x100;
            searcher.Properties.Clear();
            searcher.Properties.Add("lDAPDisplayName");
            searcher.Properties.Add("subClassOf");
            searcher.Properties.Add("systemMayContain");
            searcher.Properties.Add("mayContain");
            searcher.Properties.Add("mustContain");
            searcher.Properties.Add("systemMustContain");
            searcher.Properties.Add("auxiliaryClass");
            searcher.Properties.Add("systemAuxiliaryClass");
            IEnumerable <ADObject> aDObjects = searcher.FindAll();

            foreach (ADObject aDObject in aDObjects)
            {
                if (!aDObject.Contains("lDAPDisplayName") || aDObject["lDAPDisplayName"].Value == null)
                {
                    continue;
                }
                adSchema._schemaClasses.Add((string)aDObject["lDAPDisplayName"].Value, aDObject);
                adSchema._schemaClassesDnHash.Add((string)aDObject["distinguishedName"].Value, (string)aDObject["lDAPDisplayName"].Value);
            }
        }
コード例 #10
0
		private static ADForestPartitionInfo GetForestPartitionInfo(ADSessionInfo sessionInfo)
		{
			ADForestPartitionInfo forestPartitionInfo;
			using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo))
			{
				forestPartitionInfo = ADForestPartitionInfo.GetForestPartitionInfo(aDObjectSearcher.GetRootDSE());
			}
			return forestPartitionInfo;
		}
コード例 #11
0
ファイル: ADObjectSearcher.cs プロジェクト: nickchal/pash
		public List<ADObject> PagedSearch(ref object pageCookie, out bool hasSizeLimitExceeded, int pageSize, int sizeLimit)
		{
			hasSizeLimitExceeded = false;
			Dictionary<string, ADObject> strs = null;
			HashSet<string> strs1 = null;
			HashSet<string> strs2 = null;
			int num = -2147483648;
			this.Init();
			if (this._searchRoot != null)
			{
				ADPageResultRequestControl aDPageResultRequestControl = new ADPageResultRequestControl(pageSize);
				if (pageCookie != null)
				{
					aDPageResultRequestControl.Cookie = pageCookie;
				}
				ADSearchRequest aDSearchRequest = this.CreateSearchRequest(aDPageResultRequestControl);
				aDSearchRequest.SizeLimit = sizeLimit;
				ADSearchResponse aDSearchResponse = this._syncOps.Search(this._sessionHandle, aDSearchRequest);
				this.ProcessResponseControls(aDSearchResponse);
				if (aDSearchResponse.ResultCode == ResultCode.SizeLimitExceeded)
				{
					hasSizeLimitExceeded = true;
				}
				List<ADObject> aDObjects = new List<ADObject>(aDSearchResponse.Entries.Count);
				if (this._autoRangeRetrieve)
				{
					strs = new Dictionary<string, ADObject>(StringComparer.OrdinalIgnoreCase);
					strs1 = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
					strs2 = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
				}
				foreach (ADObject entry in aDSearchResponse.Entries)
				{
					ADObject aDObject = this.CreateRichADObject(entry);
					aDObjects.Add(aDObject);
					if (!this._autoRangeRetrieve)
					{
						continue;
					}
					if (!string.IsNullOrEmpty (aDObject.DistinguishedName))
					{
						strs.Add(aDObject.DistinguishedName, aDObject);
						ADObjectSearcher.ExtractRangeRetrievalDataFromAttributes(aDObject, aDObject, strs1, strs2, ref num);
					}
				}
				while (this._autoRangeRetrieve && strs2.Count > 0 && strs1.Count > 0 && num != -2147483648)
				{
					using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(this._adSession.SessionInfo))
					{
						IEnumerable<ADObject> aDObjects1 = ADObjectSearcher.FetchRemainingRangeRetrievalAttributeValues(aDObjectSearcher, this, strs1, strs2, num);
						strs1.Clear();
						strs2.Clear();
						num = -2147483648;
						foreach (ADObject aDObject1 in aDObjects1)
						{
							ADObjectSearcher.ExtractRangeRetrievalDataFromAttributes(aDObject1, strs[aDObject1.DistinguishedName], strs1, strs2, ref num);
						}
					}
				}
				pageCookie = null;
				DirectoryControl[] controls = aDSearchResponse.Controls;
				int num1 = 0;
				while (num1 < (int)controls.Length)
				{
					if (controls[num1] as ADPageResultResponseControl == null)
					{
						num1++;
					}
					else
					{
						pageCookie = ((ADPageResultResponseControl)controls[num1]).Cookie;
						break;
					}
				}
				return aDObjects;
			}
			else
			{
				DebugLogger.LogWarning("ADObjectSearcher", "PagedSearch: SearchRoot is null");
				throw new ArgumentNullException("SearchRoot");
			}
		}
コード例 #12
0
ファイル: ADObjectSearcher.cs プロジェクト: nickchal/pash
		private static IEnumerable<ADObject> FetchRemainingRangeRetrievalAttributeValues(ADObjectSearcher newSearcher, ADObjectSearcher originalSearcher, HashSet<string> rangeRetrievedObjects, HashSet<string> rangeRetrievedAttributes, int rangeRetrievalNextIndex)
		{
			DebugLogger.LogInfo("ADObjectSearcher", string.Concat("Inside FetchRemainingRangeRetrievalAttributeValues. Fetching next range starting from: ", rangeRetrievalNextIndex));
			newSearcher.AutoRangeRetrieve = false;
			newSearcher.PageSize = originalSearcher.PageSize;
			newSearcher.Scope = originalSearcher.Scope;
			newSearcher.SearchRoot = originalSearcher.SearchRoot;
			newSearcher.SchemaTranslation = originalSearcher.SchemaTranslation;
			newSearcher.ShowDeleted = originalSearcher.ShowDeleted;
			newSearcher.ShowDeactivatedLink = originalSearcher.ShowDeactivatedLink;
			newSearcher.SuppressServerRangeRetrievalError = true;
			List<IADOPathNode> aDOPathNodes = new List<IADOPathNode>();
			foreach (string rangeRetrievedObject in rangeRetrievedObjects)
			{
				aDOPathNodes.Add(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "distinguishedName", rangeRetrievedObject));
			}
			if (aDOPathNodes.Count != 1)
			{
				newSearcher.Filter = ADOPathUtil.CreateOrClause(aDOPathNodes.ToArray());
			}
			else
			{
				newSearcher.Filter = aDOPathNodes[0];
			}
			List<string> strs = new List<string>(rangeRetrievedAttributes.Count);
			StringBuilder stringBuilder = new StringBuilder();
			foreach (string rangeRetrievedAttribute in rangeRetrievedAttributes)
			{
				stringBuilder.Remove(0, stringBuilder.Length);
				stringBuilder.Append(rangeRetrievedAttribute).Append(";range=").Append(rangeRetrievalNextIndex).Append("-*");
				strs.Add(stringBuilder.ToString());
			}
			newSearcher.Properties = strs;
			return newSearcher.FindAll();
		}
コード例 #13
0
ファイル: ADProvider.cs プロジェクト: nickchal/pash
		private ADObjectSearcher BuildADObjectSearcher(ADSessionInfo sessionInfo)
		{
			ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo);
			aDObjectSearcher.PageSize = ADProviderDefaults.InternalProviderSearchPageSize;
			return aDObjectSearcher;
		}
コード例 #14
0
ファイル: ADProvider.cs プロジェクト: nickchal/pash
		private ADObjectSearcher GetADObjectSearcher(string path, ADSearchScope scope, IADOPathNode filter, ADProviderSearchParameters parameters, PSCredential credential, ADDriveInfo extendedDriveInfo)
		{
			this.Trace(DebugLogLevel.Verbose, "Entering GetADObjectSearcher");
			ADSessionInfo sessionInfo = this.GetSessionInfo(parameters, credential, extendedDriveInfo);
			ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo);
			aDObjectSearcher.SearchRoot = path;
			aDObjectSearcher.Scope = scope;
			if (filter != null)
			{
				aDObjectSearcher.Filter = filter;
			}
			if (parameters != null)
			{
				if (parameters.Properties != null)
				{
					aDObjectSearcher.Properties.AddRange(parameters.Properties);
				}
				aDObjectSearcher.PageSize = parameters.PageSize;
			}
			if (this.GetFormatType(parameters, extendedDriveInfo) == ADPathFormat.Canonical)
			{
				aDObjectSearcher.Properties.Add("canonicalName");
			}
			this.Trace(DebugLogLevel.Verbose, "Leaving GetADObjectSearcher");
			return aDObjectSearcher;
		}
コード例 #15
0
ファイル: ADTypeConverter.cs プロジェクト: modulexcite/pash-1
        internal ADPropertyValueCollection ConvertFromRaw(DirectoryAttribute property)
        {
            string str = null;
            int    num = 0;

            this.Init();
            if (property == null || property.Count == 0)
            {
                return(null);
            }
            else
            {
                ADPropertyValueCollection aDPropertyValueCollection = new ADPropertyValueCollection();
                ADObjectSearcher.ContainsRangeRetrievalTag(property.Name, out str, out num);
                ADAttributeSyntax propertyType      = this._adSchema.GetPropertyType(str);
                string[]          values            = null;
                byte[][]          numArray          = null;
                ADAttributeSyntax aDAttributeSyntax = propertyType;
                switch (aDAttributeSyntax)
                {
                case ADAttributeSyntax.DirectoryString:
                case ADAttributeSyntax.DN:
                {
                    aDPropertyValueCollection.AddRange(property.GetValues(typeof(string)));
                    break;
                }

                case ADAttributeSyntax.OctetString:
                {
                    aDPropertyValueCollection.AddRange(property.GetValues(typeof(byte[])));
                    break;
                }

                case ADAttributeSyntax.SecurityDescriptor:
                {
                    numArray = (byte[][])property.GetValues(typeof(byte[]));
                    byte[][] numArray1 = numArray;
                    for (int i = 0; i < (int)numArray1.Length; i++)
                    {
                        byte[] numArray2 = numArray1[i];
                        ActiveDirectorySecurity activeDirectorySecurity = new ActiveDirectorySecurity();
                        activeDirectorySecurity.SetSecurityDescriptorBinaryForm(numArray2);
                        aDPropertyValueCollection.Add(activeDirectorySecurity);
                    }
                    break;
                }

                case ADAttributeSyntax.Int:
                case ADAttributeSyntax.Enumeration:
                {
                    values = (string[])property.GetValues(typeof(string));
                    string[] strArrays = values;
                    for (int j = 0; j < (int)strArrays.Length; j++)
                    {
                        string str1 = strArrays[j];
                        aDPropertyValueCollection.Add(int.Parse(str1, NumberFormatInfo.InvariantInfo));
                    }
                    break;
                }

                case ADAttributeSyntax.Int64:
                {
                    values = (string[])property.GetValues(typeof(string));
                    string[] strArrays1 = values;
                    for (int k = 0; k < (int)strArrays1.Length; k++)
                    {
                        string str2 = strArrays1[k];
                        aDPropertyValueCollection.Add(long.Parse(str2, NumberFormatInfo.InvariantInfo));
                    }
                    break;
                }

                case ADAttributeSyntax.Bool:
                {
                    values = (string[])property.GetValues(typeof(string));
                    string[] strArrays2 = values;
                    for (int l = 0; l < (int)strArrays2.Length; l++)
                    {
                        string str3 = strArrays2[l];
                        if (string.Compare(str3, "TRUE", StringComparison.OrdinalIgnoreCase) != 0)
                        {
                            aDPropertyValueCollection.Add(false);
                        }
                        else
                        {
                            aDPropertyValueCollection.Add(true);
                        }
                    }
                    break;
                }

                case ADAttributeSyntax.Oid:
                case ADAttributeSyntax.DNWithBinary:
                case ADAttributeSyntax.DNWithString:
                case ADAttributeSyntax.IA5String:
                case ADAttributeSyntax.PrintableString:
                {
                    aDPropertyValueCollection.AddRange(property.GetValues(typeof(string)));
                    break;
                }

                case ADAttributeSyntax.GeneralizedTime:
                case ADAttributeSyntax.UtcTime:
                {
                    values = (string[])property.GetValues(typeof(string));
                    string[] strArrays3 = values;
                    for (int m = 0; m < (int)strArrays3.Length; m++)
                    {
                        string str4 = strArrays3[m];
                        aDPropertyValueCollection.Add(ADTypeConverter.ParseDateTimeValue(str4, propertyType));
                    }
                    break;
                }

                case ADAttributeSyntax.Sid:
                {
                    numArray = (byte[][])property.GetValues(typeof(byte[]));
                    byte[][] numArray3 = numArray;
                    for (int n = 0; n < (int)numArray3.Length; n++)
                    {
                        byte[] numArray4 = numArray3[n];
                        aDPropertyValueCollection.Add(new SecurityIdentifier(numArray4, 0));
                    }
                    break;
                }

                default:
                {
                    if (aDAttributeSyntax == ADAttributeSyntax.ReplicaLink)
                    {
                        aDPropertyValueCollection.AddRange(property.GetValues(typeof(byte[])));
                        break;
                    }
                    aDPropertyValueCollection.AddRange(property.GetValues(typeof(string)));
                    break;
                }
                }
                return(aDPropertyValueCollection);
            }
        }
コード例 #16
0
        public List <ADObject> PagedSearch(ref object pageCookie, out bool hasSizeLimitExceeded, int pageSize, int sizeLimit)
        {
            hasSizeLimitExceeded = false;
            Dictionary <string, ADObject> strs = null;
            HashSet <string> strs1             = null;
            HashSet <string> strs2             = null;
            int num = -2147483648;

            this.Init();
            if (this._searchRoot != null)
            {
                ADPageResultRequestControl aDPageResultRequestControl = new ADPageResultRequestControl(pageSize);
                if (pageCookie != null)
                {
                    aDPageResultRequestControl.Cookie = pageCookie;
                }
                ADSearchRequest aDSearchRequest = this.CreateSearchRequest(aDPageResultRequestControl);
                aDSearchRequest.SizeLimit = sizeLimit;
                ADSearchResponse aDSearchResponse = this._syncOps.Search(this._sessionHandle, aDSearchRequest);
                this.ProcessResponseControls(aDSearchResponse);
                if (aDSearchResponse.ResultCode == ResultCode.SizeLimitExceeded)
                {
                    hasSizeLimitExceeded = true;
                }
                List <ADObject> aDObjects = new List <ADObject>(aDSearchResponse.Entries.Count);
                if (this._autoRangeRetrieve)
                {
                    strs  = new Dictionary <string, ADObject>(StringComparer.OrdinalIgnoreCase);
                    strs1 = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                    strs2 = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
                }
                foreach (ADObject entry in aDSearchResponse.Entries)
                {
                    ADObject aDObject = this.CreateRichADObject(entry);
                    aDObjects.Add(aDObject);
                    if (!this._autoRangeRetrieve)
                    {
                        continue;
                    }
                    if (!string.IsNullOrEmpty(aDObject.DistinguishedName))
                    {
                        strs.Add(aDObject.DistinguishedName, aDObject);
                        ADObjectSearcher.ExtractRangeRetrievalDataFromAttributes(aDObject, aDObject, strs1, strs2, ref num);
                    }
                }
                while (this._autoRangeRetrieve && strs2.Count > 0 && strs1.Count > 0 && num != -2147483648)
                {
                    using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(this._adSession.SessionInfo))
                    {
                        IEnumerable <ADObject> aDObjects1 = ADObjectSearcher.FetchRemainingRangeRetrievalAttributeValues(aDObjectSearcher, this, strs1, strs2, num);
                        strs1.Clear();
                        strs2.Clear();
                        num = -2147483648;
                        foreach (ADObject aDObject1 in aDObjects1)
                        {
                            ADObjectSearcher.ExtractRangeRetrievalDataFromAttributes(aDObject1, strs[aDObject1.DistinguishedName], strs1, strs2, ref num);
                        }
                    }
                }
                pageCookie = null;
                DirectoryControl[] controls = aDSearchResponse.Controls;
                int num1 = 0;
                while (num1 < (int)controls.Length)
                {
                    if (controls[num1] as ADPageResultResponseControl == null)
                    {
                        num1++;
                    }
                    else
                    {
                        pageCookie = ((ADPageResultResponseControl)controls[num1]).Cookie;
                        break;
                    }
                }
                return(aDObjects);
            }
            else
            {
                DebugLogger.LogWarning("ADObjectSearcher", "PagedSearch: SearchRoot is null");
                throw new ArgumentNullException("SearchRoot");
            }
        }
コード例 #17
0
ファイル: ADSchema.cs プロジェクト: nickchal/pash
		private HashSet<string> GetUserSubClasses(ADObjectSearcher searcher, ADRootDSE rootDSE)
		{
			HashSet<string> strs = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
			searcher.SearchRoot = rootDSE.SchemaNamingContext;
			searcher.Properties.Add("lDAPDisplayName");
			string str = string.Concat("CN=Person,", rootDSE.SchemaNamingContext);
			IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "classSchema");
			IADOPathNode aDOPathNode1 = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "subClassOf", "user");
			IADOPathNode aDOPathNode2 = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "defaultObjectCategory", str);
			IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2];
			aDOPathNodeArray[0] = aDOPathNode;
			IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[2];
			aDOPathNodeArray1[0] = aDOPathNode1;
			aDOPathNodeArray1[1] = aDOPathNode2;
			aDOPathNodeArray[1] = ADOPathUtil.CreateAndClause(aDOPathNodeArray1);
			IADOPathNode aDOPathNode3 = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
			searcher.Filter = aDOPathNode3;
			IEnumerable<ADObject> aDObjects = searcher.FindAll();
			foreach (ADObject aDObject in aDObjects)
			{
				var ldapDisplayName = aDObject["lDAPDisplayName"];
				if (ldapDisplayName != null)
				{
					if (ldapDisplayName.Count > 0)
					{
						strs.Add((string)ldapDisplayName[0]);
					}
				}
			}
			strs.Add("user");
			return strs;
		}
コード例 #18
0
ファイル: ADSchema.cs プロジェクト: nickchal/pash
		private void Init()
		{
			if (this._schemaProperties == null)
			{
				ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(this._sessionInfo);

				{
					ADRootDSE rootDSE = aDObjectSearcher.GetRootDSE();
					this._subSchemaDN = rootDSE.SubSchemaSubEntry;
					ADSchema aDSchema = null;
					lock (ADSchema._schemaTableLock)
					{
						ADSchema._schemaTable.TryGetValue(this._subSchemaDN, out aDSchema);
					}
					if (aDSchema != null)
					{
						this._schemaProperties = aDSchema._schemaProperties;
						this._userSubClasses = aDSchema._userSubClasses;
						this._schemaClasses = aDSchema._schemaClasses;
						this._schemaClassesDnHash = aDSchema._schemaClassesDnHash;
					}
					if (this._schemaProperties == null)
					{
						if (rootDSE.ServerType == ADServerType.ADDS && this._sessionInfo.ConnectedToGC)
						{
							this._sessionInfo.SetEffectivePort(LdapConstants.LDAP_PORT);
							aDObjectSearcher.Dispose();
							aDObjectSearcher = new ADObjectSearcher(this._sessionInfo);
						}
						this._schemaProperties = new Dictionary<string, ADSchemaAttribute>(1, StringComparer.OrdinalIgnoreCase);
						this.ReadConstructedSchema(aDObjectSearcher, this);
						this.ReadObjectSchema(aDObjectSearcher, this);
						this._userSubClasses = this.GetUserSubClasses(aDObjectSearcher, rootDSE);
					}
					else
					{
						return;
					}
				}
				aDObjectSearcher.Dispose ();
				lock (ADSchema._schemaTableLock)
				{
					if (ADSchema._schemaTable.ContainsKey(this._subSchemaDN))
					{
						ADSchema._schemaTable.Remove(this._subSchemaDN);
					}
					ADSchema._schemaTable.Add(this._subSchemaDN, this);
				}
				return;
			}
			else
			{
				return;
			}
		}
コード例 #19
0
ファイル: ADSchema.cs プロジェクト: nickchal/pash
		private void PopulateSchemaClasses()
		{
			if (this._schemaClasses == null)
			{
				ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(this._sessionInfo);
				{
					ADRootDSE rootDSE = aDObjectSearcher.GetRootDSE();
					this._subSchemaDN = rootDSE.SubSchemaSubEntry;
					if (rootDSE.ServerType == ADServerType.ADDS && this._sessionInfo.ConnectedToGC)
					{
						this._sessionInfo.SetEffectivePort(LdapConstants.LDAP_PORT);
						aDObjectSearcher.Dispose();
						aDObjectSearcher = new ADObjectSearcher(this._sessionInfo);
					}
					this._schemaClasses = new Dictionary<string, ADObject>(1, StringComparer.OrdinalIgnoreCase);
					this._schemaClassesDnHash = new Dictionary<string, string>(1, StringComparer.OrdinalIgnoreCase);
					this.AddSchemaClassObjects(aDObjectSearcher, this);
				}
				aDObjectSearcher.Dispose ();
				lock (ADSchema._schemaTableLock)
				{
					ADSchema aDSchema = null;
					lock (ADSchema._schemaTableLock)
					{
						ADSchema._schemaTable.TryGetValue(this._subSchemaDN, out aDSchema);
						if (aDSchema != null)
						{
							aDSchema._schemaClasses = this._schemaClasses;
							aDSchema._schemaClassesDnHash = this._schemaClassesDnHash;
						}
					}
				}
				return;
			}
			else
			{
				return;
			}
		}
コード例 #20
0
ファイル: ADSchema.cs プロジェクト: nickchal/pash
		private void ReadConstructedSchema(ADObjectSearcher searcher, ADSchema adSchema)
		{
			searcher.SchemaTranslation = false;
			ADRootDSE rootDSE = searcher.GetRootDSE();
			searcher.SearchRoot = rootDSE.SubSchemaSubEntry;
			searcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Like, "objectClass", "*");
			searcher.Scope = ADSearchScope.Base;
			searcher.Properties.Clear();
			searcher.Properties.Add("extendedAttributeInfo");
			searcher.Properties.Add("attributeTypes");
			ADObject aDObject = searcher.FindOne();
			int success = SchemaConstants.AttributeTypesRegex.GroupNumberFromName(SchemaConstants.NameGroup);
			int num = SchemaConstants.AttributeTypesRegex.GroupNumberFromName(SchemaConstants.SyntaxGroup);
			int num1 = SchemaConstants.AttributeTypesRegex.GroupNumberFromName(SchemaConstants.SingleValueGroup);
			adSchema._schemaProperties = new Dictionary<string, ADSchemaAttribute>(1, StringComparer.OrdinalIgnoreCase);
			foreach (string item in aDObject["attributeTypes"])
			{
				Match match = SchemaConstants.AttributeTypesRegex.Match(item);
				if (match != null)
				{
					if (!match.Groups[success].Success)
					{
						DebugLogger.LogError("adschema", string.Format("AttributeType {0} no match on Name", item));
					}
					if (!match.Groups[num].Success)
					{
						DebugLogger.LogError("adschema", string.Format("AttributeType {0} no match on Syntax", item));
					}
					adSchema._schemaProperties.Add(match.Groups[success].Value, new ADSchemaAttribute(ADSyntax.OIDToSyntax(match.Groups[num].Value), match.Groups[num1].Success, false));
				}
				else
				{
					DebugLogger.LogError("adschema", string.Format("unable to match AttributeType {0}", item));
					throw new ADException();
				}
			}
			success = SchemaConstants.ExtendedAttrInfoRegex.GroupNumberFromName(SchemaConstants.NameGroup);
			int num2 = SchemaConstants.ExtendedAttrInfoRegex.GroupNumberFromName(SchemaConstants.SystemOnlyGroup);
			foreach (string str in aDObject["extendedAttributeInfo"])
			{
				Match match1 = SchemaConstants.ExtendedAttrInfoRegex.Match(str);
				adSchema._schemaProperties[match1.Groups[success].Value].IsSystemOnly = match1.Groups[num2].Success;
			}
		}
コード例 #21
0
 public ADObjectSearchResult(ADObjectSearcher searcher, int pageSize, int sizeLimit)
 {
     this._searcher  = searcher;
     this._pageSize  = pageSize;
     this._sizeLimit = sizeLimit;
 }
コード例 #22
0
 public ADObjectSearchResult(ADObjectSearcher searcher)
 {
     this._searcher  = searcher;
     this._pageSize  = this._searcher.PageSize;
     this._sizeLimit = this._searcher.SizeLimit;
 }
コード例 #23
0
ファイル: ADTypeConverter.cs プロジェクト: modulexcite/pash-1
        internal ADPropertyValueCollection ConvertFromRaw(string propertyName, ADPropertyValueCollection propertyValues)
        {
            string str = null;
            int    num = 0;
            ADPropertyValueCollection aDPropertyValueCollection;

            byte[] bytes;
            this.Init();
            if (propertyValues.Count != 0)
            {
                ADObjectSearcher.ContainsRangeRetrievalTag(propertyName, out str, out num);
                ADAttributeSyntax propertyType      = this._adSchema.GetPropertyType(str);
                ADAttributeSyntax aDAttributeSyntax = propertyType;
                switch (aDAttributeSyntax)
                {
                case ADAttributeSyntax.DirectoryString:
                case ADAttributeSyntax.DN:
                {
                    aDPropertyValueCollection = propertyValues;
                    break;
                }

                case ADAttributeSyntax.OctetString:
                {
                    aDPropertyValueCollection = propertyValues;
                    break;
                }

                case ADAttributeSyntax.SecurityDescriptor:
                {
                    aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count);
                    IEnumerator enumerator = propertyValues.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            byte[] current = (byte[])enumerator.Current;
                            ActiveDirectorySecurity activeDirectorySecurity = new ActiveDirectorySecurity();
                            activeDirectorySecurity.SetSecurityDescriptorBinaryForm(current);
                            aDPropertyValueCollection.Add(activeDirectorySecurity);
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable = enumerator as IDisposable;
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }

                case ADAttributeSyntax.Int:
                case ADAttributeSyntax.Enumeration:
                {
                    aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count);
                    IEnumerator enumerator1 = propertyValues.GetEnumerator();
                    try
                    {
                        while (enumerator1.MoveNext())
                        {
                            string current1 = (string)enumerator1.Current;
                            aDPropertyValueCollection.Add(int.Parse(current1, NumberFormatInfo.InvariantInfo));
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable1 = enumerator1 as IDisposable;
                        if (disposable1 != null)
                        {
                            disposable1.Dispose();
                        }
                    }
                }

                case ADAttributeSyntax.Int64:
                {
                    aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count);
                    IEnumerator enumerator2 = propertyValues.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            string str1 = (string)enumerator2.Current;
                            aDPropertyValueCollection.Add(long.Parse(str1, NumberFormatInfo.InvariantInfo));
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable2 = enumerator2 as IDisposable;
                        if (disposable2 != null)
                        {
                            disposable2.Dispose();
                        }
                    }
                }

                case ADAttributeSyntax.Bool:
                {
                    aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count);
                    IEnumerator enumerator3 = propertyValues.GetEnumerator();
                    try
                    {
                        while (enumerator3.MoveNext())
                        {
                            string current2 = (string)enumerator3.Current;
                            if (string.Compare(current2, "TRUE", StringComparison.OrdinalIgnoreCase) != 0)
                            {
                                aDPropertyValueCollection.Add(false);
                            }
                            else
                            {
                                aDPropertyValueCollection.Add(true);
                            }
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable3 = enumerator3 as IDisposable;
                        if (disposable3 != null)
                        {
                            disposable3.Dispose();
                        }
                    }
                }

                case ADAttributeSyntax.Oid:
                case ADAttributeSyntax.DNWithBinary:
                case ADAttributeSyntax.DNWithString:
                case ADAttributeSyntax.IA5String:
                case ADAttributeSyntax.PrintableString:
                {
                    aDPropertyValueCollection = propertyValues;
                    break;
                }

                case ADAttributeSyntax.GeneralizedTime:
                case ADAttributeSyntax.UtcTime:
                {
                    aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count);
                    IEnumerator enumerator4 = propertyValues.GetEnumerator();
                    try
                    {
                        while (enumerator4.MoveNext())
                        {
                            string str2 = (string)enumerator4.Current;
                            aDPropertyValueCollection.Add(ADTypeConverter.ParseDateTimeValue(str2, propertyType));
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable4 = enumerator4 as IDisposable;
                        if (disposable4 != null)
                        {
                            disposable4.Dispose();
                        }
                    }
                }

                case ADAttributeSyntax.Sid:
                {
                    aDPropertyValueCollection = new ADPropertyValueCollection(propertyValues.Count);
                    IEnumerator enumerator5 = propertyValues.GetEnumerator();
                    try
                    {
                        while (enumerator5.MoveNext())
                        {
                            object obj = enumerator5.Current;
                            if (obj as string == null)
                            {
                                bytes = (byte[])obj;
                            }
                            else
                            {
                                bytes = ADTypeConverter._encoder.GetBytes((string)obj);
                            }
                            aDPropertyValueCollection.Add(new SecurityIdentifier(bytes, 0));
                        }
                        break;
                    }
                    finally
                    {
                        IDisposable disposable5 = enumerator5 as IDisposable;
                        if (disposable5 != null)
                        {
                            disposable5.Dispose();
                        }
                    }
                }

                default:
                {
                    aDPropertyValueCollection = propertyValues;
                    break;
                }
                }
                return(aDPropertyValueCollection);
            }
            else
            {
                return(null);
            }
        }
コード例 #24
0
		private void Refresh(ADRootDSE rootDSE)
		{
			if (rootDSE != null)
			{
				if (rootDSE.SessionInfo != null)
				{
					if (this._forestId.Equals(rootDSE.SubSchemaSubEntry, StringComparison.OrdinalIgnoreCase))
					{
						object[] objArray = new object[1];
						objArray[0] = this._forestId;
						DebugLogger.LogInfo("ADForestPartitionInfo", "Refreshing PartitionList of Forest: {0}", objArray);
						List<string> strs = new List<string>();
						ADSessionInfo sessionInfo = rootDSE.SessionInfo;
						if (rootDSE.ServerType == ADServerType.ADDS && sessionInfo.ConnectedToGC)
						{
							sessionInfo = sessionInfo.Copy();
							sessionInfo.SetEffectivePort(LdapConstants.LDAP_PORT);
						}
						using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo))
						{
							aDObjectSearcher.SchemaTranslation = false;
							aDObjectSearcher.SearchRoot = string.Concat("CN=Partitions,", rootDSE.ConfigurationNamingContext);
							aDObjectSearcher.Properties.Add("nCName");
							aDObjectSearcher.Filter = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "crossRef");
							foreach (ADObject aDObject in aDObjectSearcher.FindAll())
							{
								if (aDObject["nCName"] == null || aDObject["nCName"].Count <= 0)
								{
									continue;
								}
								strs.Add((string)aDObject["nCName"][0]);
							}
							this._forestPartitionList = new ReadOnlyCollection<string>(strs);
						}
						return;
					}
					else
					{
						throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, StringResources.ForestIdDoesNotMatch, new object[0]));
					}
				}
				else
				{
					throw new ArgumentNullException("rootDSE.SessionInfo");
				}
			}
			else
			{
				throw new ArgumentNullException("rootDSE");
			}
		}
コード例 #25
0
        private static IEnumerable <ADObject> FetchRemainingRangeRetrievalAttributeValues(ADObjectSearcher newSearcher, ADObjectSearcher originalSearcher, HashSet <string> rangeRetrievedObjects, HashSet <string> rangeRetrievedAttributes, int rangeRetrievalNextIndex)
        {
            DebugLogger.LogInfo("ADObjectSearcher", string.Concat("Inside FetchRemainingRangeRetrievalAttributeValues. Fetching next range starting from: ", rangeRetrievalNextIndex));
            newSearcher.AutoRangeRetrieve   = false;
            newSearcher.PageSize            = originalSearcher.PageSize;
            newSearcher.Scope               = originalSearcher.Scope;
            newSearcher.SearchRoot          = originalSearcher.SearchRoot;
            newSearcher.SchemaTranslation   = originalSearcher.SchemaTranslation;
            newSearcher.ShowDeleted         = originalSearcher.ShowDeleted;
            newSearcher.ShowDeactivatedLink = originalSearcher.ShowDeactivatedLink;
            newSearcher.SuppressServerRangeRetrievalError = true;
            List <IADOPathNode> aDOPathNodes = new List <IADOPathNode>();

            foreach (string rangeRetrievedObject in rangeRetrievedObjects)
            {
                aDOPathNodes.Add(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "distinguishedName", rangeRetrievedObject));
            }
            if (aDOPathNodes.Count != 1)
            {
                newSearcher.Filter = ADOPathUtil.CreateOrClause(aDOPathNodes.ToArray());
            }
            else
            {
                newSearcher.Filter = aDOPathNodes[0];
            }
            List <string> strs          = new List <string>(rangeRetrievedAttributes.Count);
            StringBuilder stringBuilder = new StringBuilder();

            foreach (string rangeRetrievedAttribute in rangeRetrievedAttributes)
            {
                stringBuilder.Remove(0, stringBuilder.Length);
                stringBuilder.Append(rangeRetrievedAttribute).Append(";range=").Append(rangeRetrievalNextIndex).Append("-*");
                strs.Add(stringBuilder.ToString());
            }
            newSearcher.Properties = strs;
            return(newSearcher.FindAll());
        }
コード例 #26
0
ファイル: ADSchema.cs プロジェクト: nickchal/pash
		internal string GetRDNPrefix(string objectClass)
		{
			ADObject aDObject;
			ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(this._sessionInfo);
			using (aDObjectSearcher)
			{
				ADRootDSE rootDSE = aDObjectSearcher.GetRootDSE();
				aDObjectSearcher.SearchRoot = rootDSE.SchemaNamingContext;
				aDObjectSearcher.Properties.Add("rDNAttID");
				IADOPathNode aDOPathNode = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "classSchema");
				IADOPathNode aDOPathNode1 = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "lDAPDisplayName", objectClass);
				IADOPathNode[] aDOPathNodeArray = new IADOPathNode[2];
				aDOPathNodeArray[0] = aDOPathNode;
				aDOPathNodeArray[1] = aDOPathNode1;
				IADOPathNode aDOPathNode2 = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
				aDObjectSearcher.Filter = aDOPathNode2;
				aDObject = aDObjectSearcher.FindOne();
			}
			if (aDObject == null)
			{
				return null;
			}
			else
			{
				return (string)aDObject["rDNAttID"][0];
			}
		}
コード例 #27
0
 public ADObjectSearchResultEnumerator(ADObjectSearcher searcher) : this(searcher, searcher.PageSize, searcher.SizeLimit)
 {
 }
コード例 #28
0
ファイル: ADSchema.cs プロジェクト: nickchal/pash
		private void ReadObjectSchema(ADObjectSearcher searcher, ADSchema adSchema)
		{
			searcher.SchemaTranslation = false;
			ADRootDSE rootDSE = searcher.GetRootDSE();
			searcher.SearchRoot = rootDSE.SchemaNamingContext;
			IADOPathNode[] aDOPathNodeArray = new IADOPathNode[3];
			aDOPathNodeArray[0] = ADOPathUtil.CreateNotClause(ADOPathUtil.CreateFilterClause(ADOperator.Eq, "isDefunct", true));
			aDOPathNodeArray[1] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "objectClass", "attributeSchema");
			IADOPathNode[] aDOPathNodeArray1 = new IADOPathNode[3];
			aDOPathNodeArray1[0] = ADOPathUtil.CreateFilterClause(ADOperator.Eq, "attributeSyntax", SchemaConstants.SidAttributeSyntax);
			aDOPathNodeArray1[1] = ADOPathUtil.CreateFilterClause(ADOperator.Like, "linkID", "*");
			aDOPathNodeArray1[2] = ADOPathUtil.CreateFilterClause(ADOperator.Band, "systemFlags", SchemaConstants.systemFlagsConstructedBitMask);
			aDOPathNodeArray[2] = ADOPathUtil.CreateOrClause(aDOPathNodeArray1);
			searcher.Filter = ADOPathUtil.CreateAndClause(aDOPathNodeArray);
			searcher.Scope = ADSearchScope.Subtree;
			searcher.PageSize = 0x100;
			searcher.Properties.Clear();
			searcher.Properties.Add("lDAPDisplayName");
			searcher.Properties.Add("linkID");
			searcher.Properties.Add("systemFlags");
			searcher.Properties.Add("attributeSyntax");
			IEnumerable<ADObject> aDObjects = searcher.FindAll();

			foreach (ADObject nullable in aDObjects)
			{
				if (adSchema._schemaProperties.ContainsKey ((string)nullable["lDAPDisplayName"].Value))
				{
					if (nullable.Contains("linkID"))
					{
						adSchema._schemaProperties[(string)nullable["lDAPDisplayName"].Value].LinkID = new int?(int.Parse(nullable["linkID"].Value as string, NumberFormatInfo.InvariantInfo));
					}
					if (nullable.Contains("systemFlags") && (long)0 != (ulong.Parse(nullable["systemFlags"].Value as string, NumberFormatInfo.InvariantInfo) & SchemaConstants.systemFlagsConstructedBitMask))
					{
						adSchema._schemaProperties[(string)nullable["lDAPDisplayName"].Value].IsConstructed = true;
					}
					if (!nullable.Contains("attributeSyntax") || string.Compare(nullable["attributeSyntax"].Value as string, SchemaConstants.SidAttributeSyntax, true) != 0)
					{
						continue;
					}
					adSchema._schemaProperties[(string)nullable["lDAPDisplayName"].Value].Syntax = ADAttributeSyntax.Sid;
				}
			}
		}