Exemplo n.º 1
0
 private void Init()
 {
     if (this._adSchema == null)
     {
         this._adSchema = new ADSchema(this._sessionInfo);
     }
 }
Exemplo n.º 2
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);
			}
		}
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
 private void Init()
 {
     if (this._adSchema == null)
     {
         this._adSchema = new ADSchema(this._sessionInfo);
     }
     if (this._adTypeConverter == null)
     {
         this._adTypeConverter = new ADTypeConverter(this._sessionInfo);
     }
 }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
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;
                }
            }
        }
Exemplo n.º 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;
     }
 }
Exemplo n.º 8
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);
            }
        }
Exemplo n.º 9
0
		private void Init()
		{
			if (this._adSchema == null)
			{
				this._adSchema = new ADSchema(this._sessionInfo);
			}
			if (this._adTypeConverter == null)
			{
				this._adTypeConverter = new ADTypeConverter(this._sessionInfo);
			}
		}
Exemplo n.º 10
0
		private void Init()
		{
			if (this._adSchema == null)
			{
				this._adSchema = new ADSchema(this._sessionInfo);
			}
		}
Exemplo n.º 11
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;
				}
			}
		}
Exemplo n.º 12
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;
			}
		}