November Happy Hour will be moved to Thursday December 5th.

Class ActiveDirectoryRoleProvider

ASP.NET 2.0 Role provider for Microsofts Active Directory.

Inheritance
System.Object
ActiveDirectoryRoleProvider
Namespace: EPiServer.Security
Assembly: EPiServer.dll
Version: 10.10.4
Syntax
[ProviderCapability((ProviderActions)0, WildcardSymbol = "*")]
public class ActiveDirectoryRoleProvider : RoleProvider
Remarks

This role provider is designed to work together with the default Systwm.Web.Security.ActiveDirectoryMembershipProvider, although there are no hard dependencies.

Constructors

ActiveDirectoryRoleProvider()

Declaration
public ActiveDirectoryRoleProvider()

Properties

ApplicationName

Gets or sets the name of the application to store and retrieve role information for.

Declaration
public override string ApplicationName { get; set; }
Property Value
Type Description
System.String

DirectoryDataFactory

Gets or sets the directory data factory.

Declaration
public DirectoryDataFactory DirectoryDataFactory { get; set; }
Property Value
Type Description
DirectoryDataFactory

The directory data factory.

Remarks

This is used to access the actual Directory service class that contains the directory service specifics.

Methods

AddUsersToRoles(String[], String[])

Adds the specified user names to the specified roles for the configured applicationName.

Declaration
public override void AddUsersToRoles(string[] usernames, string[] roleNames)
Parameters
Type Name Description
System.String[] usernames

A string array of user names to be added to the specified roles.

System.String[] roleNames

A string array of the role names to add the specified user names to.

Remarks

This method is not supported in this provider.

CreateRole(String)

Adds a new role to the data source for the configured applicationName.

Declaration
public override void CreateRole(string roleName)
Parameters
Type Name Description
System.String roleName

The name of the role to create.

Remarks

This method is not supported in this provider.

DeleteRole(String, Boolean)

Removes a role from the data source for the configured applicationName.

Declaration
public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
Parameters
Type Name Description
System.String roleName

The name of the role to delete.

System.Boolean throwOnPopulatedRole

If true, throw an exception if roleName has one or more members and do not delete roleName.

Returns
Type Description
System.Boolean

true if the role was successfully deleted; otherwise, false.

Remarks

This method is not supported in this provider.

FindUsersInRole(String, String)

Gets an array of user names in a role where the user name contains the specified user name to match.

Declaration
public override string[] FindUsersInRole(string roleName, string usernameToMatch)
Parameters
Type Name Description
System.String roleName

The role to search in.

System.String usernameToMatch

The user name to search for.

Returns
Type Description
System.String[]

A string array containing the names of all the users where the user name matches usernameToMatch and the user is a member of the specified role.

GetAllRoles()

Gets a list of all the roles for the configured applicationName.

Declaration
public override string[] GetAllRoles()
Returns
Type Description
System.String[]

A string array containing the names of all the roles stored in the data source for the configured applicationName.

GetRolesForUser(String)

Gets a list of the roles that a specified user is in for the configured applicationName.

Declaration
public override string[] GetRolesForUser(string username)
Parameters
Type Name Description
System.String username

The user to return a list of roles for.

Returns
Type Description
System.String[]

A string array containing the names of all the roles that the specified user is in for the configured applicationName.

GetUsersInRole(String)

Gets a list of users in the specified role for the configured applicationName.

Declaration
public override string[] GetUsersInRole(string roleName)
Parameters
Type Name Description
System.String roleName

The name of the role to get the list of users for.

Returns
Type Description
System.String[]

A string array containing the names of all the users who are members of the specified role for the configured applicationName.

Initialize(String, NameValueCollection)

Initializes the provider.

Declaration
public override void Initialize(string name, NameValueCollection config)
Parameters
Type Name Description
System.String name

The friendly name of the provider.

System.Collections.Specialized.NameValueCollection config

A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.

Exceptions
Type Condition
System.ArgumentNullException

The name of the provider is null.

System.InvalidOperationException

An attempt is made to call System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection) on a provider after the provider has already been initialized.

System.ArgumentException

The name of the provider has a length of zero.

IsUserInRole(String, String)

Gets a value indicating whether the specified user is in the specified role for the configured applicationName.

Declaration
public override bool IsUserInRole(string userName, string roleName)
Parameters
Type Name Description
System.String userName

The user name to search for.

System.String roleName

The role to search in.

Returns
Type Description
System.Boolean

true if the specified user is in the specified role for the configured applicationName; otherwise, false.

RemoveUsersFromRoles(String[], String[])

Removes the specified user names from the specified roles for the configured applicationName.

Declaration
public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
Parameters
Type Name Description
System.String[] usernames

A string array of user names to be removed from the specified roles.

System.String[] roleNames

A string array of role names to remove the specified user names from.

Remarks

This method is not supported in this provider.

RoleExists(String)

Gets a value indicating whether the specified role name already exists in the role data source for the configured applicationName.

Declaration
public override bool RoleExists(string roleName)
Parameters
Type Name Description
System.String roleName

The name of the role to search for in the data source.

Returns
Type Description
System.Boolean

true if the role name already exists in the data source for the configured applicationName; otherwise, false.

Extension Methods