예제 #1
0
        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]);
            }
        }
예제 #2
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;
            }
        }
예제 #3
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;
		}
예제 #4
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;
			}
		}
예제 #5
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];
			}
		}