Share via


DirectoryEntry.SchemaEntry

The SchemaEntry property gets the DirectoryEntry that holds schema information for this entry. An entry's schema determines a list of its mandatory and optional property names.

public DirectoryEntry SchemaEntry {get;}
Public ReadOnly Property SchemaEntry As DirectoryEntry

Property Value

The DirectoryEntry that holds schema information for this entry.

Remarks

You can use this entry to find out what properties and methods are available on the associated object.

Example Code [Visual Basic .NET]

The following snippet demonstrates the SchemaClassName and SchemaEntry properties of the DirectoryEntry class. This example gets the user-specified DirectoryEntry and gets all it's Children if the SchemaEntry is of type container.

Dim myADSPath As String = "LDAP://onecity/CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com"

' Creates an Instance of DirectoryEntry.
Dim myDirectoryEntry As New DirectoryEntry(myADSPath, "user", "password")

' Display the 'SchemaClassName'.
Console.WriteLine("Schema class name:" + myDirectoryEntry.SchemaClassName)

' Gets the SchemaEntry of the ADS object.
Dim mySchemaEntry As DirectoryEntry = myDirectoryEntry.SchemaEntry

If String.Compare(mySchemaEntry.Name, "container") = 0 Then
   Dim myChildDirectoryEntry As DirectoryEntry
   For Each myChildDirectoryEntry In  myDirectoryEntry.Children
      Console.WriteLine(myChildDirectoryEntry.Path)
   Next

Example Code [C#]

The following snippet demonstrates the SchemaClassName and SchemaEntry properties of the DirectoryEntry class. This example gets the user-specified DirectoryEntry and gets all it's Children if the SchemaEntry is of type container.

String myADSPath = "LDAP://onecity/CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com";

// Creates an Instance of DirectoryEntry.
DirectoryEntry  myDirectoryEntry=new DirectoryEntry(myADSPath,"user","password");

// Display the 'SchemaClassName'.
Console.WriteLine("Schema class name:"+myDirectoryEntry.SchemaClassName);

// Gets the SchemaEntry of the ADS object.
DirectoryEntry mySchemaEntry = myDirectoryEntry.SchemaEntry;

if (string.Compare(mySchemaEntry.Name,"container") == 0)
{
   foreach(DirectoryEntry myChildDirectoryEntry in myDirectoryEntry.Children)
      Console.WriteLine(myChildDirectoryEntry.Path);
}

Example Code [Managed C++]

The following snippet demonstrates the SchemaClassName and SchemaEntry properties of the DirectoryEntry class. This example gets the user-specified DirectoryEntry and gets all it's Children if the SchemaEntry is of type container.

String* myADSPath = S"LDAP://onecity/CN=Users,DC=onecity,DC=corp,DC=fabrikam,DC=com";

// Creates an Instance of DirectoryEntry.
DirectoryEntry* myDirectoryEntry = new DirectoryEntry(myADSPath, S"user", S"password");

// Display the 'SchemaClassName'.
Console::WriteLine(S"Schema class name:{0}", myDirectoryEntry->SchemaClassName);

// Gets the SchemaEntry of the ADS Object*.
DirectoryEntry* mySchemaEntry = myDirectoryEntry->SchemaEntry;

if (!String::Compare(mySchemaEntry->Name, S"container")) {
    Collections::IEnumerator* myEnum = myDirectoryEntry->Children->GetEnumerator();
    while (myEnum->MoveNext()) {
        DirectoryEntry* myChildDirectoryEntry = __try_cast<DirectoryEntry*>(myEnum->Current);
        Console::WriteLine(myChildDirectoryEntry->Path);
    }
}

Requirements

Client Requires Windows XP Home Edition, Windows XP Professional, Windows Me, or Windows 98.
Server Requires Windows Server 2003, Windows 2000, or Windows NT 4.0.
Namespace

Defined in System.DirectoryServices.

Assembly

Requires System.DirectoryServices (in System.DirectoryServices.dll).

.NET Framework

Requires .NET Framework 1.0.