Class AdsiDataFactory
Concrete implementation of the EpiServer.Security.DirectoryDataFactory base class, using ActiveDirectory Services Interface (ADSI) to interface with a LDAP server.
Inherited Members
Namespace: EPiServer.Security
Assembly: EPiServer.dll
Version: 10.10.4Syntax
public class AdsiDataFactory : DirectoryDataFactory
Constructors
AdsiDataFactory()
Initializes a new instance of the AdsiDataFactory class.
Declaration
public AdsiDataFactory()
AdsiDataFactory(String, String, String, AuthenticationTypes, TimeSpan)
Initializes a new instance of the DirectoryDataFactory class.
Declaration
public AdsiDataFactory(string connectionString, string username, string password, AuthenticationTypes connectionProtection, TimeSpan absoluteCacheTimeout)
Parameters
Type | Name | Description |
---|---|---|
System.String | connectionString | The connection string. |
System.String | username | The username. |
System.String | password | The password. |
System.DirectoryServices.AuthenticationTypes | connectionProtection | The connection protection. |
System.TimeSpan | absoluteCacheTimeout | The absolute cache timeout. |
Remarks
Create and initialize an instance of this class for accessing Active Directory data.
Properties
ConnectionProtection
Gets or sets the connection protection.
Declaration
public AuthenticationTypes ConnectionProtection { get; protected set; }
Property Value
Type | Description |
---|---|
System.DirectoryServices.AuthenticationTypes | The connection protection. |
Remarks
Defines the type and level of protection for the Active Directory communications.
ConnectionString
Gets or sets the connection string.
Declaration
public string ConnectionString { get; protected set; }
Property Value
Type | Description |
---|---|
System.String | The connection string. |
Remarks
The string for connecting to the Active Directory server. It should be in the format LDAP://dns.name.for.machine or LDAP://dns.name.for.active.directory.domain
PageSize
Gets or sets the page size
Declaration
public int PageSize { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
The maximum number of objects the server can return in a paged search. The default is zero, which means do not do a paged search.
Password
Gets or sets the password.
Declaration
public string Password { get; protected set; }
Property Value
Type | Description |
---|---|
System.String | The password. |
Remarks
The password used, together with the Username, to connect to the Active Directory domain.
Username
Gets or sets the user name.
Declaration
public string Username { get; protected set; }
Property Value
Type | Description |
---|---|
System.String | The user name. |
Remarks
The user name to use for connecting to the Active Directory domain as defined by ConnectionString.
Methods
AddPropertyToLoad(String)
Adds a property to load on access to Active Directory.
Declaration
public override void AddPropertyToLoad(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | Name of the property. |
Overrides
Remarks
This class keeps a list of property names to query for whenever an Active Directory entry is retrieved. By calling this method you can expand this list with custom properties.
ClearCache()
Clears the Active Directory cache.
Declaration
public void ClearCache()
CreateDirectoryDataFromDirectoryEntry(DirectoryEntry)
Creates a directory data object from a directory entry.
Declaration
protected DirectoryData CreateDirectoryDataFromDirectoryEntry(DirectoryEntry entry)
Parameters
Type | Name | Description |
---|---|---|
System.DirectoryServices.DirectoryEntry | entry | The System.DirectoryServices.DirectoryEntry. |
Returns
Type | Description |
---|---|
DirectoryData | A DirectoryData object populated with information from |
Remarks
DirectoryData can be viewed as a Data Transfer Object, craeting an implementation-independent representation of the data to avoid tying the implementetation too tightly to the System.DirectoryServices namespace.
CreateDirectoryDataFromSearchResult(SearchResult)
Creates a directory data instance from search result.
Declaration
protected DirectoryData CreateDirectoryDataFromSearchResult(SearchResult result)
Parameters
Type | Name | Description |
---|---|---|
System.DirectoryServices.SearchResult | result | The result. |
Returns
Type | Description |
---|---|
DirectoryData | The populated DirectoryData instance. |
Remarks
DirectoryData can be viewed as a Data Transfer Object, craeting an implementation-independent representation of the data to avoid tying the implementetation too tightly to the System.DirectoryServices namespace.
CreateDirectoryEntry()
Creates a directory entry.
Declaration
protected DirectoryEntry CreateDirectoryEntry()
Returns
Type | Description |
---|---|
System.DirectoryServices.DirectoryEntry | An initialized System.DirectoryServices.DirectoryEntry |
Remarks
The directory entry is configured with connection string, user credentials etc.
CreateDirectoryEntry(String)
Creates a directory entry.
Declaration
protected DirectoryEntry CreateDirectoryEntry(string rootDistinguishedName)
Parameters
Type | Name | Description |
---|---|---|
System.String | rootDistinguishedName | Distinguished name of the root where the directory entry is used. |
Returns
Type | Description |
---|---|
System.DirectoryServices.DirectoryEntry | An initialized System.DirectoryServices.DirectoryEntry, or null if |
DistinguishedName(Dictionary<String, String[]>)
Gets the distinguisheds name from a dictionary.
Declaration
protected string DistinguishedName(Dictionary<string, string[]> properties)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, System.String[]> | properties | The properties as collected from a System.DirectoryServices.DirectoryEntry. |
Returns
Type | Description |
---|---|
System.String | A string with the distinguished name. |
Remarks
Primarily used internally when converting from DirectoryEntry to DirectoryData.
EscapeDistinguishedName(String)
Escapes reserved characters in the distinguished name.
Declaration
protected string EscapeDistinguishedName(string distinguishedName)
Parameters
Type | Name | Description |
---|---|---|
System.String | distinguishedName | The distinguished name. |
Returns
Type | Description |
---|---|
System.String | The escaped representation of the string. |
Remarks
The following characters will be escaped by prefixing them with a backslash (): Carriage return, Linefeed, '+', '', '"', '<', '>', ';', '/'
FindAll(String, SearchScope, String)
Finds all directory entries that match the filter criteria.
Declaration
public override IList<DirectoryData> FindAll(string filter, SearchScope scope, string sortByProperty)
Parameters
Type | Name | Description |
---|---|---|
System.String | filter | The LDAP filter. |
System.DirectoryServices.SearchScope | scope | The search scope. |
System.String | sortByProperty | The property to sort directory entries by. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IList<DirectoryData> | An IList of DirectoryData objects, sorted by the indicated property. |
Overrides
Remarks
If sortByProperty is set to null, the list will be returned without sorting. This method will make use of caching, if the serach has already beem done, the result will be returned without accessing Active Directory.
FindOne(String, SearchScope)
Find on Active Directory entry based on search filter.
Declaration
public override DirectoryData FindOne(string filter, SearchScope scope)
Parameters
Type | Name | Description |
---|---|---|
System.String | filter | The filter, which is a LDAP query. |
System.DirectoryServices.SearchScope | scope | The scope at which to search. |
Returns
Type | Description |
---|---|
DirectoryData | A DirectoryData instance with the entry, or null if the search did not find an entry. |
Overrides
Remarks
This method uses caching to speed up the operation, if the DirectoryData object is found in the cache, no communication with the Active Directory domain will take place.
GetEntry(String)
Gets a specific Active Directory entry as a DirectoryData object.
Declaration
public override DirectoryData GetEntry(string distinguishedName)
Parameters
Type | Name | Description |
---|---|---|
System.String | distinguishedName | Distinguished name of the entry. |
Returns
Type | Description |
---|---|
DirectoryData | A DirectoryData instance containing the properties defined by PropertiesToLoad. |
Overrides
Remarks
This method uses caching to speed up the operation, if the DirectoryData object is found in the cache, no communication with the Active Directory domain will take place.
Initialize(NameValueCollection)
Initializes an instance of the DirectoryDataFactory class.
Declaration
public override void Initialize(NameValueCollection config)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Specialized.NameValueCollection | config | The configuration data to use. |
Overrides
Remarks
This method is intended to be called from within a providers Initialize method. It will read its settings from the config parameter and initialize this instance. Required settings in config are: connectionStringName = name of the connection string to use for connecting to the Active Directory server. connectionUsername = username for the connection. connectionPassword = password for the connection.
Optional settings in config are: connectionProtection = level of protection and security for the Active Directory connection. None or Secure (default). cacheTimeout = how long cached Active Directory entries stys in the cache. Default is 10 minutes.
SchemaClassName(Dictionary<String, String[]>)
Gets the schema class name from a dictionary.
Declaration
protected string SchemaClassName(Dictionary<string, string[]> properties)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, System.String[]> | properties | The properties as collected from a System.DirectoryServices.DirectoryEntry. |
Returns
Type | Description |
---|---|
System.String | A string with the schema class name. |
Remarks
Primarily used internally when converting from DirectoryEntry to DirectoryData.
StoreInCache(String, Object)
Stores the data in cache.
Declaration
protected void StoreInCache(string cacheKey, object data)
Parameters
Type | Name | Description |
---|---|---|
System.String | cacheKey | The cache key. |
System.Object | data | The data. |
TryGetDestructive(NameValueCollection, String, out String)
Get value from from config and remove it if found.
Declaration
protected bool TryGetDestructive(NameValueCollection config, string name, out string value)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Specialized.NameValueCollection | config | The collection of configuration values. |
System.String | name | The name of the parameter. |
System.String | value | The value of the parameter. |
Returns
Type | Description |
---|---|
System.Boolean | True if the parameter was found, False otherwise. |