Ausgabe der Partitionen eines Ads
Autor: Dr. Holger Schwichtenberg
' --- Pfade für Active DirectoryConst DOMAIN As String = "DC=IT-Visions,DC=de"Const SERVER As String = "LDAP://sonne2000/"Const USER As String = "cn=H.Schwichtenberg"Const OU As String = "ou=Basta"Const GROUP As String = "cn=Sprecher"Const LDAProot As String = SERVER & DOMAINConst LDAPusers As String = SERVER & "CN=users," & _DOMAINConst LDAPhs As String = SERVER & USER & "," & OU & "," & DOMAINConst LDAPbasta As String = SERVER & OU & "," & DOMAINConst LDAPsprecher As String = SERVER & GROUP & "," & _OU & "," & DOMAINConst ADMINUSER As String = "sonnensystem\admin"Const ADMINPASSWORD As String = "egal"' ============================' .NET-Code-Beispiel in Visual Basic .NET' Ausgabe der Partitionen eines ADs' (C) Holger@Schwichtenberg.de' ============================Sub ADS_partitionen() Dim de As DirectoryEntry ' --- Zugriff auf RootDSE (serverloses Binden) de = New DirectoryEntry("LDAP://rootDSE") ' --- Ausgabe des Servernamens out("Servername: " & de.Properties("Servername")(0)) ' --- Ausgabe der Partitionen out("defaultNamingContext: " & _ de.Properties("defaultNamingContext")(0)) out("ConfigurationNamingContext: " & _ de.Properties("ConfigurationNamingContext")(0)) out("SchemaNamingContext: " & de.Properties("SchemaNamingContext")(0))End Sub
using System;using System.DirectoryServices;using ActiveDs;namespace FCLBuch._SystemDirectoryServices { public class Samples_ADSI { // Pfade für Active Directory const string DOMAIN = "DC=IT-Visions,DC=de"; const string SERVER = "LDAP://sonne2000/"; const string USER = "cn=H.Schwichtenberg"; const string OU = "ou=Basta"; const string GROUP = "cn=Sprecher"; const string LDAProot = SERVER + DOMAIN; const string LDAPusers = SERVER + "CN=users," + DOMAIN; const string LDAPhs = SERVER + USER + "," + OU + "," + DOMAIN; const string LDAPbasta = SERVER + OU + "," + DOMAIN; const string LDAPsprecher = SERVER + GROUP + "," + OU + "," + DOMAIN; const string ADMINUSER = "sonnensystem\administrator"; const string ADMINPASSWORD = "xxx"; public void ADS_Partitionen() { // Ausgabe der Partitionen eines ADS // Zugriff auf RootDSE (serverloses Binden) DirectoryEntry de = new DirectoryEntry("LDAP://rootDSE"); // Ausgabe des Servernamens FclOutput.PrintOut("Servername: " + de.Properties["Servername"][0]); // Ausgabe der Partitionen FclOutput.PrintOut("defaultNamingContext: " + de.Properties["defaultNamingContext"][0]); FclOutput.PrintOut("ConfigurationNamingContext: " + de.Properties["ConfigurationNamingContext"][0]); FclOutput.PrintOut("SchemaNamingContext: " + de.Properties["SchemaNamingContext"][0]); }}}
Definition '.NET Framework Class Library' Verfügbarkeit der Klasse 'System.DirectoryServices.DirectoryEntry' Übersicht über den FCL-Namensraum 'System.DirectoryServices' .NET & Visual Studio Community Portal