private void PopulateMsLapsSchemaStatus()
        {
            try
            {
                this.MsLapsSchemaPresentText      = "Checking...";
                this.MsLapsSchemaLookupInProgress = true;
                this.IsMsLapsSchemaPresent        = false;
                this.IsNotMsLapsSchemaPresent     = false;

                var schema = ActiveDirectorySchema.GetSchema(new DirectoryContext(DirectoryContextType.Forest, this.Forest.Name));
                schema.FindProperty("ms-Mcs-AdmPwd");
                this.IsMsLapsSchemaPresent   = true;
                this.MsLapsSchemaPresentText = "Present";
            }
            catch (ActiveDirectoryObjectNotFoundException)
            {
                this.IsNotMsLapsSchemaPresent = true;
                this.MsLapsSchemaPresentText  = "Not present";
            }
            catch (Exception ex)
            {
                this.logger.LogError(EventIDs.UISchemaLookupError, ex, "Could not determine Microsoft LAPS schema status");
                this.IsNotMsLapsSchemaPresent = true;
                this.MsLapsSchemaPresentText  = "Error looking up schema";
            }
            finally
            {
                this.MsLapsSchemaLookupInProgress = false;
            }
        }
コード例 #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());
        }
        private void PopulateLithnetSchemaStatus()
        {
            try
            {
                this.LithnetAccessManagerSchemaPresentText = "Checking...";
                this.LithnetSchemaLookupInProgress         = true;
                this.IsLithnetSchemaPresent    = false;
                this.IsNotLithnetSchemaPresent = false;

                var schema = ActiveDirectorySchema.GetSchema(new DirectoryContext(DirectoryContextType.Forest, this.Forest.Name));
                schema.FindProperty("lithnetAdminPassword");
                this.IsLithnetSchemaPresent = true;
                this.LithnetAccessManagerSchemaPresentText = "Present";
            }
            catch (ActiveDirectoryObjectNotFoundException)
            {
                this.IsNotLithnetSchemaPresent             = true;
                this.LithnetAccessManagerSchemaPresentText = "Not present";
            }
            catch (Exception ex)
            {
                this.logger.LogError(EventIDs.UISchemaLookupError, ex, "Could not determine Lithnet Access Manager schema status");
                this.IsNotLithnetSchemaPresent             = true;
                this.LithnetAccessManagerSchemaPresentText = "Error looking up schema";
            }
            finally
            {
                this.LithnetSchemaLookupInProgress = false;
            }
        }
コード例 #4
0
ファイル: SchemaExtender.cs プロジェクト: bmachek/NMLS
        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();
        }
コード例 #5
0
        public void GetSchemaNamingContextEasy()
        {
            ActiveDirectorySchema ads = ActiveDirectorySchema.GetCurrentSchema();

            using (ads)
                using (DirectoryEntry entry = ads.GetDirectoryEntry())
                {
                    //bound to schema partition
                }
        }
コード例 #6
0
 public void TestForestSchema()
 {
     using (Forest forest = Forest.GetForest(ActiveDirectoryContext))
     {
         using (ActiveDirectorySchema schema = forest.Schema)
             using (ActiveDirectorySchemaClass adsc = schema.FindClass("top"))
             {
                 Assert.True("top".Equals(adsc.CommonName, StringComparison.OrdinalIgnoreCase));
             }
     }
 }
コード例 #7
0
        public void TestSchemaFilter()
        {
            // using (ActiveDirectorySchemaClass schema = ActiveDirectorySchemaClass.FindByName(ActiveDirectoryContext, "user"))
            using (ActiveDirectorySchema schema = ActiveDirectorySchema.GetSchema(ActiveDirectoryContext))
                using (DirectoryEntry de = schema.GetDirectoryEntry())
                {
                    // by default there is no filters
                    Assert.Equal(0, de.Children.SchemaFilter.Count);

                    int topClassCount = 0;

                    foreach (DirectoryEntry child in de.Children)
                    {
                        string s = (string)child.Properties["objectClass"][0];
                        topClassCount += s.Equals("top", StringComparison.OrdinalIgnoreCase) ? 1 : 0;
                    }

                    de.Children.SchemaFilter.Add("top");
                    Assert.Equal(1, de.Children.SchemaFilter.Count);
                    Assert.True(de.Children.SchemaFilter.Contains("top"));
                    Assert.Equal(0, de.Children.SchemaFilter.IndexOf("top"));
                    Assert.Equal("top", de.Children.SchemaFilter[0]);

                    int newTopClassCount = 0;

                    foreach (DirectoryEntry child in de.Children)
                    {
                        // we expect to get top only entries
                        string s = (string)child.Properties["objectClass"][0];
                        Assert.True(s.Equals("top", StringComparison.OrdinalIgnoreCase));
                        newTopClassCount += 1;
                    }

                    Assert.Equal(topClassCount, newTopClassCount);

                    de.Children.SchemaFilter.Remove("top");
                    Assert.Equal(0, de.Children.SchemaFilter.Count);

                    de.Children.SchemaFilter.Add("top");
                    Assert.Equal(1, de.Children.SchemaFilter.Count);
                    de.Children.SchemaFilter.RemoveAt(0);
                    Assert.Equal(0, de.Children.SchemaFilter.Count);

                    de.Children.SchemaFilter.AddRange(new string [] { "top", "user" });
                    Assert.Equal(2, de.Children.SchemaFilter.Count);
                    de.Children.SchemaFilter.Insert(0, "person");
                    Assert.Equal(3, de.Children.SchemaFilter.Count);
                    Assert.Equal("person", de.Children.SchemaFilter[0]);
                    Assert.Equal("user", de.Children.SchemaFilter[2]);

                    de.Children.SchemaFilter.Clear();
                    Assert.Equal(0, de.Children.SchemaFilter.Count);
                }
        }
コード例 #8
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();
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
        /// <summary>
        /// Returns the AD ObjectClass associated with a particular
        /// Connector ObjectClass
        /// </summary>
        /// <param name="oclass"></param>
        /// <returns></returns>
        internal String GetADObjectClass(ObjectClass oclass)
        {
            if (oclass.Equals(ObjectClass.ACCOUNT))
            {
                return(_configuration.ObjectClass);
            }
            else if (ActiveDirectoryConnector.groupObjectClass.Equals(oclass))
            {
                return("Group");
            }
            else if (ActiveDirectoryConnector.ouObjectClass.Equals(oclass))
            {
                return("organizationalUnit");
            }
            else
            {
                // It's not something I know about, so I'll consult the AD schema.
                // if it's there, fine, but if not throw an exception.

                //first check to see if we have seen it before.
                String objectClassName = oclass.GetObjectClassValue();
                if (_knownObjectClasses.Contains(objectClassName))
                {
                    return(objectClassName);
                }

                // if we havent seen it before, consult AD's schema
                ActiveDirectorySchema      ADSchema      = GetADSchema();
                ActiveDirectorySchemaClass ADSchemaClass = null;
                try
                {
                    ADSchemaClass = ADSchema.FindClass(objectClassName);
                    _knownObjectClasses.Add(objectClassName);
                    return(objectClassName);
                }
                catch (ActiveDirectoryObjectNotFoundException exception)
                {
                    String msg = _configuration.ConnectorMessages.Format(
                        "ex_ObjectClassInvalidForConnector",
                        "ObjectClass \'{0}\' is not valid for this connector",
                        objectClassName);
                    throw new ConnectorException(msg);
                }
            }
        }
コード例 #11
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);
 }
コード例 #12
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);
 }
コード例 #13
0
        public void TestSchema()
        {
            using (ActiveDirectorySchema schema = ActiveDirectorySchema.GetSchema(ActiveDirectoryContext))
            {
                Assert.True(schema.FindAllClasses().Contains(ActiveDirectorySchemaClass.FindByName(ActiveDirectoryContext, "user")));
                Assert.True(schema.FindAllClasses().Contains(ActiveDirectorySchemaClass.FindByName(ActiveDirectoryContext, "samDomainBase")));
                Assert.NotNull(schema.FindAllDefunctClasses());
                Assert.NotNull(schema.FindAllDefunctProperties());
                Assert.True(schema.FindAllProperties(PropertyTypes.Indexed).Contains(ActiveDirectorySchemaProperty.FindByName(ActiveDirectoryContext, "ou")));
                Assert.True(schema.FindAllProperties().Contains(ActiveDirectorySchemaProperty.FindByName(ActiveDirectoryContext, "cn")));
                Assert.Equal("person", schema.FindClass("person").Name);
                Assert.Equal("cn", schema.FindProperty("cn").Name);

                using (DirectoryEntry de = schema.GetDirectoryEntry())
                {
                    Assert.True("CN=Schema".Equals(de.Name, StringComparison.OrdinalIgnoreCase));
                }
            }
        }
コード例 #14
0
        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);
                }
            }
        }
コード例 #15
0
        internal ActiveDirectorySchema GetADSchema()
        {
            String serverName = _configuration.LDAPHostName;
            Forest forest     = null;

            if ((serverName == null) || (serverName.Length == 0))
            {
                // get the active directory schema
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Trying to lookup Domain controller for domain {0}",
                                  _configuration.DomainName);

                DirectoryContext context = new DirectoryContext(
                    DirectoryContextType.Domain,
                    _configuration.DomainName,
                    _configuration.DirectoryAdminName,
                    _configuration.DirectoryAdminPassword);

                DomainController dc = DomainController.FindOne(context);
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Found Domain controller named {0} with ipAddress {1} for domain {2}",
                                  dc.Name, dc.IPAddress, _configuration.DomainName);
                forest = dc.Forest;
                LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Found forest");
            }
            else
            {
                DirectoryContext context = new DirectoryContext(
                    DirectoryContextType.DirectoryServer,
                    _configuration.LDAPHostName,
                    _configuration.DirectoryAdminName,
                    _configuration.DirectoryAdminPassword);
                forest = Forest.GetForest(context);
            }

            LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Getting schema from AD");
            ActiveDirectorySchema ADSchema = forest.Schema;

            LOGGER.TraceEvent(TraceEventType.Verbose, CAT_DEFAULT, "Got schema from AD");

            return(ADSchema);
        }
コード例 #16
0
        public List <String> GetAllADUserProperties(string domain) //"dcs.azdcs.gov"
        {
            List <String> properties = new List <String>();

            IPAddress[] ips = Dns.GetHostAddresses(domain).Where(w => w.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToArray();
            if (ips.Length > 0)
            {
                DirectoryContext           directoryContext = new DirectoryContext(DirectoryContextType.Forest);//DirectoryContextType.DirectoryServer, ips[0].ToString() + ":389", Username, Password);
                ActiveDirectorySchema      adschema         = ActiveDirectorySchema.GetSchema(directoryContext);
                ActiveDirectorySchemaClass adschemaclass    = adschema.FindClass("User");

                // Read the OptionalProperties & MandatoryProperties
                ReadOnlyActiveDirectorySchemaPropertyCollection propcol = adschemaclass.GetAllProperties();

                foreach (ActiveDirectorySchemaProperty schemaProperty in propcol)
                {
                    properties.Add(schemaProperty.Name.ToLower());
                }
            }

            return(properties);
        }
コード例 #17
0
        private ReadUserResponse GetUserInfo(Principal up)
        {
            using (var o = (DirectoryEntry)up.GetUnderlyingObject())
            {
                //Lekérdezem az összes attributumot, azt is, amit
                //nem töltöttek még ki. Erre azért van szükség, mert
                //ha nincs kitöltve egy attributum, akkor nem nem kapok
                //róla vissza adatot
                var adschema      = ActiveDirectorySchema.GetSchema(directoryContext);
                var adschemaclass = adschema.FindClass(GlobalStrings.User);
                var allAttributes = adschemaclass.GetAllProperties();

                //jogosultság lista lekérése, majd az attributumok erre a listára szűrése
                o.RefreshCache(new string[] { GlobalStrings.AllowedAttributesEffective });
                //ide jön az írható attributumok listája
                var writableProperties = new List <string>();
                foreach (ActiveDirectorySchemaProperty item in allAttributes)
                {
                    if (o.Properties[GlobalStrings.AllowedAttributesEffective].Contains(item.Name))
                    {
                        writableProperties.Add(item.Name);
                    }
                }

                //és ezek az adatok kellenek nekünk
                var user = new ReadUserResponse
                {
                    DisplayName       = up.DisplayName,
                    Description       = up.Description,
                    DistinguishedName = up.DistinguishedName,
                    Name = up.Name,
                    Sid  = up.Sid,
                    UserPrincipalName = up.UserPrincipalName,
                    SamAccountName    = up.SamAccountName,
                };

                //az előbb a cache-t leszűkítettem az allowedAttributesEffective
                //attributumra, mert máshogy nem tudtam betölteni. Így viszont újra kell
                //a cache-t frissíteni
                o.RefreshCache();
                var fields = o.Properties;

                foreach (string fieldName in writableProperties)
                {
                    var list = new List <AdhrValue>();
                    if (fields[fieldName].Value != null)
                    {
                        foreach (var item in fields[fieldName])
                        {
                            list.Add(new AdhrValue(item.ToString()));
                        }
                    }
                    else
                    {
                        list.Add(new AdhrValue(null));
                    }
                    user.Properties.Add(fieldName, new ReadOnlyCollection <AdhrValue>(list));
                }

                return(user);
            }
        }
コード例 #18
0
ファイル: MainForm.cs プロジェクト: vinicius-zhu/ADUpdate
        public void buttonRunQuery_Click(object sender, EventArgs e)
        {
            Setup  setup      = new Setup();
            String OldOraHome = Environment.GetEnvironmentVariable("ORACLE_HOME");

            if (!String.IsNullOrEmpty(setup.textBoxOraHome.Text))
            {
                Environment.SetEnvironmentVariable("ORACLE_HOME", setup.textBoxOraHome.Text);
            }
            OracleConnection conn = new OracleConnection(setup.ConnectionStringOracle);

            try
            {
                conn.Open();
                OracleCommand cmd = new OracleCommand();
                cmd.Connection  = conn;
                cmd.CommandText = "SELECT column_name FROM all_tab_columns WHERE upper(table_name) = upper('" +
                                  setup.textBoxOraView.Text + "') ORDER BY column_name ASC";
                cmd.CommandType = CommandType.Text;
                OracleDataReader dr = cmd.ExecuteReader();
                m_Fields.Clear();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        try
                        {
                            m_Fields.Add(dr[0].ToString());
                        }
                        catch
                        {
                        }
                    }
                }

                m_Fields.Add("*BRANCO*");
                m_Fields.Sort();
                dr.Close();
                conn.Dispose();
                dataGridView.Rows.Clear();
                DataGridViewComboBoxColumn column = dataGridView.Columns["CampoOrigem"] as DataGridViewComboBoxColumn;
                if (column != null)
                {
                    column.DataSource = m_Fields;
                }

                List <String> properties = new List <String>();
                properties.Clear();
                IPAddress[] ips =
                    Dns.GetHostAddresses(setup.textBoxLdapServer.Text)
                    .Where(w => w.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                    .ToArray();
                if (ips.Length > 0)
                {
                    DirectoryContext directoryContext = new DirectoryContext(DirectoryContextType.DirectoryServer,
                                                                             ips[0].ToString() + ":389", setup.textBoxLdapUsername.Text, setup.textBoxLdapPassword.Text);
                    ActiveDirectorySchema      adschema      = ActiveDirectorySchema.GetSchema(directoryContext);
                    ActiveDirectorySchemaClass adschemaclass = adschema.FindClass("User");

                    // Read the OptionalProperties & MandatoryProperties
                    ReadOnlyActiveDirectorySchemaPropertyCollection propcol = adschemaclass.GetAllProperties();

                    foreach (ActiveDirectorySchemaProperty schemaProperty in propcol)
                    {
                        properties.Add(schemaProperty.Name.ToLower());
                    }
                }
                DataGridViewComboBoxColumn column2 = dataGridView.Columns["CampoDestino"] as DataGridViewComboBoxColumn;
                if (column2 != null)
                {
                    column2.DataSource = properties;
                }

                try
                {
                    FileInfo file = new FileInfo(Path.Combine(Application.StartupPath, "DePara.xml"));
                    if (file.Exists)
                    {
                        Dictionary <Int32, Dictionary <String, String> > data =
                            new Dictionary <int, Dictionary <string, string> >();
                        XmlReader xr = XmlReader.Create(file.FullName);
                        xr.MoveToContent();
                        while (xr.Read())
                        {
                            Dictionary <String, String> attributes = new Dictionary <string, string>();
                            while (xr.MoveToNextAttribute())
                            {
                                if (xr.Name != "CampoOrigem" && xr.Name != "CampoDestino")
                                {
                                    continue;
                                }
                                attributes.Add(xr.Name, xr.Value);
                            }
                            if (attributes.Count > 0)
                            {
                                data.Add(data.Count, attributes);
                            }
                        }
                        xr.Close();
                        foreach (KeyValuePair <Int32, Dictionary <String, String> > kp in data)
                        {
                            dataGridView.Rows.Add(kp.Value["CampoOrigem"], kp.Value["CampoDestino"]);
                        }
                    }
                }
                catch
                {
                }
            }
            catch (Exception exc)
            {
                try
                {
                    MessageBox.Show(exc.Message, "Erro ao conectar com o BD", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch
                {
                }
            }
            if (!String.IsNullOrEmpty(setup.textBoxOraHome.Text))
            {
                Environment.SetEnvironmentVariable("ORACLE_HOME", OldOraHome);
            }
        }
コード例 #19
0
        public static void GetSchemaData()
        {
            Console.WriteLine("<--SCHEMA Information-->\n");

            ActiveDirectorySchema schema;

            try
            {
                // bind to the schema associated with the ADAM instance
                schema = ActiveDirectorySchema.GetSchema(adamContext);
            }
            catch (ActiveDirectoryObjectNotFoundException e)
            {
                // current context could not be obtained
                Console.WriteLine(e.Message);
                return;
            }

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

            // get all class names
            Console.WriteLine("\nAll schema classes:");
            foreach (ActiveDirectorySchemaClass schemaClass in
                     schema.FindAllClasses())
            {
                Console.WriteLine("Common name: {0}\n\tlDAPDisplayName: {1}",
                                  schemaClass.CommonName, schemaClass.Name);
            }


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

            // get all the defunct classes in the schema
            // This searches for all classes with the isDefunct attribute set to True
            // You cannot instantiate a defunct class. Since you cannot delete an
            // attribute, setting an attribute to defunct is the next best thing.
            // By default, an ADAM instance doesn't contain any defunct classes.
            Console.WriteLine("\nAll defunct schema classes:");
            foreach (ActiveDirectorySchemaClass schemaClass in
                     schema.FindAllDefunctClasses())
            {
                Console.WriteLine(schemaClass);
            }

            Console.WriteLine("\nAll defunct schema attributes:");

            foreach (ActiveDirectorySchemaProperty schemaProperty in
                     schema.FindAllDefunctProperties())
            {
                Console.WriteLine(schemaProperty);
            }

            Console.WriteLine("\nIndexed attributes:");

            foreach (ActiveDirectorySchemaProperty schemaProperty in
                     schema.FindAllProperties(
                         PropertyTypes.Indexed))
            {
                Console.WriteLine(schemaProperty);
            }
        }