Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ActiveDirectorySchema schema = ActiveDirectorySchema.GetCurrentSchema();

            DirectoryEntry searchRoot = new DirectoryEntry("LDAP://rootDSE");
            Object         domainDCs  = searchRoot.Properties["defaultNamingContext"][0];

            searchRoot.Dispose();

            Console.WriteLine("Processing for domain: " + domainDCs);

            for (int i = 1; i <= 26; i++)
            {
                char driveLetter = Convert.ToChar(i + 64);
                Console.WriteLine("Processing drive: " + driveLetter);
                createNetworkDriveAttribute(domainDCs, driveLetter, i);
            }

            schema.RefreshSchema();

            createSchemaClass(domainDCs);

            schema.RefreshSchema();

            CreateDisplaySpecifiers(domainDCs);

            searchRoot.Dispose();
        }
Exemplo n.º 2
0
        internal static void SetAvailabilityAces(SecurityIdentifier exchangeServersSid, AvailabilityConfig availabilityConfig, Task.TaskVerboseLoggingDelegate verboseLogger)
        {
            Guid schemaGuid;

            using (ActiveDirectorySchema currentSchema = ActiveDirectorySchema.GetCurrentSchema())
            {
                using (ActiveDirectorySchemaClass activeDirectorySchemaClass = currentSchema.FindClass("msExchAvailabilityAddressSpace"))
                {
                    schemaGuid = activeDirectorySchemaClass.SchemaGuid;
                }
            }
            Guid schemaGuid2;

            using (ActiveDirectorySchema currentSchema2 = ActiveDirectorySchema.GetCurrentSchema())
            {
                using (ActiveDirectorySchemaProperty activeDirectorySchemaProperty = currentSchema2.FindProperty("msExchAvailabilityUserPassword"))
                {
                    schemaGuid2 = activeDirectorySchemaProperty.SchemaGuid;
                }
            }
            DirectoryCommon.SetAces(verboseLogger, null, availabilityConfig, new List <ActiveDirectoryAccessRule>
            {
                new ActiveDirectoryAccessRule(exchangeServersSid, ActiveDirectoryRights.ReadProperty, AccessControlType.Allow, schemaGuid2, ActiveDirectorySecurityInheritance.Descendents, schemaGuid)
            }.ToArray());
        }
Exemplo n.º 3
0
        public void GetSchemaNamingContextEasy()
        {
            ActiveDirectorySchema ads = ActiveDirectorySchema.GetCurrentSchema();

            using (ads)
                using (DirectoryEntry entry = ads.GetDirectoryEntry())
                {
                    //bound to schema partition
                }
        }
Exemplo n.º 4
0
        public static void SchemaSample()
        {
            Console.WriteLine();
            Console.WriteLine("<---------SCHEMA Samples---------->\n");

            // get the schema associated with the current forest
            ActiveDirectorySchema schema;

            try
            {
                schema = ActiveDirectorySchema.GetCurrentSchema();
            }
            catch (ActiveDirectoryObjectNotFoundException e)
            {
                // current context is not associated with domain/forest
                Console.WriteLine(e.Message);
                return;
            }

            Console.WriteLine("Current schema: {0}", schema);
            Console.WriteLine();

            // get all the abstract classes in the schema
            Console.WriteLine("All abstract schema classes:");
            foreach (ActiveDirectorySchemaClass schemaClass in
                     schema.FindAllClasses(SchemaClassType.Abstract))
            {
                Console.WriteLine(schemaClass);
            }
            Console.WriteLine();

            // get all the defunct classes in the schema
            Console.WriteLine("All defunct schema classes:");
            foreach (ActiveDirectorySchemaClass schemaClass in
                     schema.FindAllDefunctClasses())
            {
                Console.WriteLine(schemaClass);
            }
            Console.WriteLine();

            // get all the properties that are indexed
            // and replicated to global catalog
            Console.WriteLine("All indexed properties that are also " +
                              "replicated to global catalog:");
            foreach (ActiveDirectorySchemaProperty schemaProperty in
                     schema.FindAllProperties(
                         PropertyTypes.Indexed |
                         PropertyTypes.InGlobalCatalog))
            {
                Console.WriteLine(schemaProperty);
            }
            Console.WriteLine();
        }
        public static void GetSchemaData()
        {
            Console.WriteLine();
            Console.WriteLine("<--SCHEMA Information-->\n");

            ActiveDirectorySchema schema;

            try
            {
                // bind to the schema in the current forest
                schema = ActiveDirectorySchema.GetCurrentSchema();
            }
            catch (ActiveDirectoryObjectNotFoundException e)
            {
                // can't bind to the schema
                Console.WriteLine(e.Message);
                return;
            }

            Console.WriteLine("Current schema: {0}\n", schema);

            // get all the abstract classes in the schema
            Console.WriteLine("All abstract schema classes:");
            foreach (ActiveDirectorySchemaClass schemaClass in
                     schema.FindAllClasses(SchemaClassType.Abstract))
            {
                Console.WriteLine(schemaClass);
            }

            // get all the defunct classes in the schema
            Console.WriteLine("\nAll defunct schema classes:");
            foreach (ActiveDirectorySchemaClass schemaClass in
                     schema.FindAllDefunctClasses())
            {
                Console.WriteLine(schemaClass);
            }

            // get all attributes that are indexed
            // and replicated to global catalog
            Console.WriteLine("\nAll indexed attributes that are also " +
                              "replicated to the global catalog:");
            foreach (ActiveDirectorySchemaProperty schemaProperty in
                     schema.FindAllProperties(
                         PropertyTypes.Indexed |
                         PropertyTypes.InGlobalCatalog))
            {
                Console.WriteLine(schemaProperty);
            }
        }
Exemplo n.º 6
0
 private static SchemaProperty GetSchemaProperty(string propertyName)
 {
     if (!schemaPropertyCache.TryGetValue(propertyName, out SchemaProperty schemaProperty))
     {
         using (ActiveDirectorySchema schema = ActiveDirectorySchema.GetCurrentSchema())
         {
             ActiveDirectorySchemaProperty           result         = schema.FindProperty(propertyName);
             System.DirectoryServices.DirectoryEntry directoryEntry = result.GetDirectoryEntry();
             schemaProperty = new SchemaProperty()
             {
                 LdapDisplayName = result.Name,
                 SchemaGuid      = result.SchemaGuid,
                 IsConfidential  = (((int)directoryEntry.Properties["searchFlags"][0] & 128) == 128)
             };
             schemaPropertyCache.Add(result.Name, schemaProperty);
         }
     }
     return(schemaProperty);
 }
Exemplo n.º 7
0
 private static SchemaClass GetSchemaClass(string className)
 {
     if (!schemaClassCache.TryGetValue(className, out SchemaClass schemaClass))
     {
         using (ActiveDirectorySchema schema = ActiveDirectorySchema.GetCurrentSchema())
         {
             ActiveDirectorySchemaClass result = schema.FindClass(className);
             System.DirectoryServices.DirectoryEntry directoryEntry = result.GetDirectoryEntry();
             schemaClass = new SchemaClass()
             {
                 LdapDisplayName   = result.Name,
                 SchemaGuid        = result.SchemaGuid,
                 DistinguishedName = (string)directoryEntry.Properties["distinguishedName"][0]
             };
             schemaClassCache.Add(result.Name, schemaClass);
         }
     }
     return(schemaClass);
 }
        static void Main(string[] args)
        {
            DirectorySearcher          deSearch   = new DirectorySearcher();
            ActiveDirectorySchema      currSchema = ActiveDirectorySchema.GetCurrentSchema();
            ActiveDirectorySchemaClass collection = currSchema.FindClass("user");
            ReadOnlyActiveDirectorySchemaPropertyCollection properties = collection.GetAllProperties();
            IEnumerator enumerator = properties.GetEnumerator();

            while (enumerator.MoveNext())
            {
                try
                {
                    deSearch.PropertiesToLoad.Add(enumerator.Current.ToString());
                }
                catch (Exception ex)
                {
                    // MessageBox.Show(ex.Message);
                }
            }
        }