DirectoryEntry Class

The DirectoryEntry class encapsulates a node or object in the Active Directory Domain Services hierarchy.

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      System.DirectoryServices.DirectoryEntry

Namespace:  System.DirectoryServices
Assembly:  System.DirectoryServices (in System.DirectoryServices.dll)

[<DSDescriptionAttribute("DirectoryEntryDesc")>]
[<SecurityPermissionAttribute(SecurityAction.Assert, Flags = SecurityPermissionFlag.UnmanagedCode)>]
[<EnvironmentPermissionAttribute(SecurityAction.Assert, Unrestricted = true)>]
[<DirectoryServicesPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)>]
type DirectoryEntry =  
    class 
        inherit Component 
    end

The DirectoryEntry type exposes the following members.

  NameDescription
Public methodDirectoryEntry()Initializes a new instance of the DirectoryEntry class.
Public methodDirectoryEntry(Object)Initializes a new instance of the DirectoryEntry class that binds to the specified native Active Directory Domain Services object.
Public methodDirectoryEntry(String)Initializes a new instance of the DirectoryEntry class that binds this instance to the node in Active Directory Domain Services located at the specified path.
Public methodDirectoryEntry(String, String, String)Initializes a new instance of the DirectoryEntry class.
Public methodDirectoryEntry(String, String, String, AuthenticationTypes)Initializes a new instance of the DirectoryEntry class.
Top

  NameDescription
Public propertyAuthenticationTypeGets or sets the type of authentication to use.
Protected propertyCanRaiseEventsGets a value indicating whether the component can raise an event. (Inherited from Component.)
Public propertyChildrenGets the child entries of this node in the Active Directory Domain Services hierarchy.
Public propertyContainerGets the IContainer that contains the Component. (Inherited from Component.)
Protected propertyDesignModeGets a value that indicates whether the Component is currently in design mode. (Inherited from Component.)
Protected propertyEventsGets the list of event handlers that are attached to this Component. (Inherited from Component.)
Public propertyGuidGets the GUID of the DirectoryEntry.
Public propertyNameGets the name of the object as named with the underlying directory service.
Public propertyNativeGuidGets the GUID of the DirectoryEntry, as returned from the provider.
Public propertyNativeObjectGets the native Active Directory Service Interfaces (ADSI) object.
Public propertyObjectSecurityGets or sets the security descriptor for this entry.
Public propertyOptionsGets the provider-specific options for this entry.
Public propertyParentGets this entry's parent in the Active Directory Domain Services hierarchy.
Public propertyPasswordSets the password to use when authenticating the client.
Public propertyPathGets or sets the path for this DirectoryEntry.
Public propertyPropertiesGets the Active Directory Domain Services properties for this DirectoryEntry object.
Public propertySchemaClassNameGets the name of the schema class for this DirectoryEntry object.
Public propertySchemaEntryGets the schema object for this entry.
Public propertySiteGets or sets the ISite of the Component. (Inherited from Component.)
Public propertyUsePropertyCacheGets or sets a value indicating whether the cache should be committed after each operation.
Public propertyUsernameGets or sets the user name to use when authenticating the client.
Top

  NameDescription
Public methodCloseCloses the DirectoryEntry object and releases any system resources that are associated with this component.
Public methodCommitChangesSaves changes that are made to a directory entry to the underlying directory store.
Public methodCopyTo(DirectoryEntry)Creates a copy of this entry as a child of the specified parent.
Public methodCopyTo(DirectoryEntry, String)Creates a copy of this DirectoryEntry object, as a child of the specified parent DirectoryEntry object, with the specified new name.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDeleteTreeDeletes this entry and its entire subtree from the Active Directory Domain Services hierarchy.
Public methodDispose()Releases all resources used by the Component. (Inherited from Component.)
Protected methodDispose(Boolean)Disposes of the resources (other than memory) that are used by the DirectoryEntry. (Overrides Component.Dispose(Boolean).)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodStatic memberExistsDetermines if the specified path represents an actual entry in the directory service.
Protected methodFinalizeReleases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected methodGetServiceReturns an object that represents a service provided by the Component or by its Container. (Inherited from Component.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodInvokeCalls a method on the native Active Directory Domain Services object.
Public methodInvokeGetGets a property from the native Active Directory Domain Services object.
Public methodInvokeSetSets a property on the native Active Directory Domain Services object.
Protected methodMemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public methodMoveTo(DirectoryEntry)Moves this DirectoryEntry object to the specified parent.
Public methodMoveTo(DirectoryEntry, String)Moves this DirectoryEntry object to the specified parent and changes its name to the specified value.
Public methodRefreshCache()Loads the property values for this DirectoryEntry object into the property cache.
Public methodRefreshCache(String[])Loads the values of the specified properties into the property cache.
Public methodRenameChanges the name of this DirectoryEntry object.
Public methodToStringReturns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.)
Top

  NameDescription
Public eventDisposedOccurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)
Top

Use this class for binding to objects, or reading and updating attributes. DirectoryEntry, along with helper classes, provides support for life-cycle management and navigation methods. These include creating, deleting, renaming, moving a child node, and enumerating children. After you modify a node, you must commit your changes in order for them to be saved to the tree. For more information, see the CommitChanges property.

DirectoryEntry can be used to access regular entries and some, but not all, information from schema entries.

The Active Directory Domain Services hierarchy contains up to several thousand nodes. Each node represents an object, such as a network printer or a user in a domain. Corporate networks constantly change as new employees are hired and objects such as network printers and computers are added. Active Directory Service Interfaces (ADSI) technology provides ways to programmatically add these objects to the directory tree.

To create a directory entry in the hierarchy, use the Children property. The Children property is a collection that provides an Add method, through which you add a node to the collection directly below the parent node that you are currently bound to. When adding a node to the collection, you must specify a name for the new node and the name of a schema template that you want to associate with the node. For example, you might want to use a schema titled "Computer" to add new computers to the hierarchy.

This class also contains attribute caching, which can be useful for optimizing network traffic. To use attribute caching, see the UsePropertyCache property.

The classes associated with the DirectoryEntry component can be used with any of the Active Directory Domain Services service providers. Some of the current providers are Internet Information Services (IIS), Lightweight Directory Access Protocol (LDAP), Novell NetWare Directory Service (NDS), and WinNT.

NoteNote

It is assumed that you have a general understanding of Active Directory Domain Services before using this class. For more information, see the System.DirectoryServices namespace overview.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft