Class ActiveDirectoryExtensions
A simple ActiveDirectory helper class
Inheritance
Inherited Members
Namespace: Dapplo.ActiveDirectory
Assembly: Dapplo.ActiveDirectory.dll
Syntax
public static class ActiveDirectoryExtensions
Methods
| Improve this Doc View SourceExecute<T>(Query, AuthenticationTypes, String, String, String)
Use the ActiveDirectory with the supplied domain to query, using the specified AuthenticationTypes
Declaration
public static IEnumerable<T> Execute<T>(this Query query, AuthenticationTypes authenticationType, string domain = null, string username = null, string password = null)
where T : IAdObject
Parameters
Type | Name | Description |
---|---|---|
Query | query | Query |
System.DirectoryServices.AuthenticationTypes | authenticationType | AuthenticationTypes used to specify the AuthenticationType, null to use the value from ActiveDirectoryGlobals.AuthenticationType |
System.String | domain | Domain for the LDAP server, if null the Domain.GetCurrentDomain().Name is used |
System.String | username | Username for the connection, by default the current user is used |
System.String | password | Password for the supplied user |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | IEnumerable with the specified type |
Type Parameters
Name | Description |
---|---|
T | Type to fill, use AdPropertyAttribute to specify the mapping |
Execute<T>(Query, String, String, String)
Use the ActiveDirectory with the supplied domain to query. The AuthenticationTypes for the connection is specified in ActiveDirectoryGlobals.AuthenticationType, or use the Execute where you can pass this.
Declaration
public static IEnumerable<T> Execute<T>(this Query query, string domain = null, string username = null, string password = null)
where T : IAdObject
Parameters
Type | Name | Description |
---|---|---|
Query | query | Query |
System.String | domain | Domain for the LDAP server, if null the Domain.GetCurrentDomain().Name is used |
System.String | username | Username for the connection, by default the current user is used |
System.String | password | Password for the supplied user |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<T> | IEnumerable with the specified type |
Type Parameters
Name | Description |
---|---|
T | Type to fill, use AdPropertyAttribute to specify the mapping |
GetByAdsPath(String, String, String)
This is more for debugging, with retrieve the complete DirectoryEntry for the AdsPath
Declaration
public static DirectoryEntry GetByAdsPath(string adsPath, string username = null, string password = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | adsPath | string with the AdsPath, this can be retrieved by setting AdProperty(AdProperties.Id) on a string property for the type passed to Execute |
System.String | username | Username for the connection, by default the current user is used |
System.String | password | Password for the supplied user |
Returns
Type | Description |
---|---|
System.DirectoryServices.DirectoryEntry | DirectoryEntry |
ToDisplayString(DirectoryEntry, String)
Convert a property in the AD to a string
Declaration
public static string ToDisplayString(this DirectoryEntry directoryEntry, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.DirectoryServices.DirectoryEntry | directoryEntry | DirectoryEntry |
System.String | propertyName | string |
Returns
Type | Description |
---|---|
System.String | string |
Update<TAdContainer>(TAdContainer, DirectoryEntry)
If you want to update information, the minimum what the passed container needs is a property with AdProperties.Id
Declaration
public static void Update<TAdContainer>(this TAdContainer adContainerObject, DirectoryEntry directoryEntry)
where TAdContainer : IAdObject
Parameters
Type | Name | Description |
---|---|---|
TAdContainer | adContainerObject | object which has the values to update |
System.DirectoryServices.DirectoryEntry | directoryEntry | DirectoryEntry |
Type Parameters
Name | Description |
---|---|
TAdContainer | The type of the AD Container object |
Update<TAdContainer>(TAdContainer, String, String)
If you want to update information, the minimum what the passed container needs is a property with AdProperties.Id
Declaration
public static void Update<TAdContainer>(this TAdContainer adContainerObject, string username = null, string password = null)
where TAdContainer : IAdObject
Parameters
Type | Name | Description |
---|---|---|
TAdContainer | adContainerObject | object which has the values to update |
System.String | username | Username for the connection, by default the current user is used |
System.String | password | Password for the supplied user |
Type Parameters
Name | Description |
---|---|
TAdContainer | The type of the AD Container object |