GetRolesForUser
<configuration> <system.web> . . . <authentication mode="Windows"/> <roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="MyRoleProvider"> <providers> <add name="MyRoleProvider" type="MyNamespace.RoleProvider" /> </providers> </roleManager> <authorization> <allow users="*" /> <deny users="?" /> </authorization> </system.web> <location path="Admin"> <system.web> <authorization> <allow roles="ADM"/> <deny users="*"/> <deny users="?"/> </authorization> </system.web> </location> . . . </configuration>
Namespace MyNamespace Public Class RoleProvider Inherits System.Web.Security.RoleProvider Public Overrides Function GetRolesForUser(ByVal username As String) As String() ' TODO: Implement this method Dim result As String() = {} Return result End Function ' These remaining methods are necessary because they are declared MustInherit in the base class. Public Overrides Sub AddUsersToRoles(ByVal usernames() As String, ByVal roleNames() As String) End Sub Public Overrides Property ApplicationName() As String Get Return "MyApp" End Get Set(ByVal value As String) End Set End Property Public Overrides Sub CreateRole(ByVal roleName As String) End Sub Public Overrides Function DeleteRole(ByVal roleName As String, ByVal throwOnPopulatedRole As Boolean) As Boolean Return False End Function Public Overrides Function FindUsersInRole(ByVal roleName As String, ByVal usernameToMatch As String) As String() Dim result As String() = {} Return result End Function Public Overrides Function GetAllRoles() As String() Dim result As String() = {} Return result End Function Public Overrides Function GetUsersInRole(ByVal roleName As String) As String() Dim result As String() = {} Return result End Function Public Overrides Function IsUserInRole(ByVal username As String, ByVal roleName As String) As Boolean Return True End Function Public Overrides Sub RemoveUsersFromRoles(ByVal usernames() As String, ByVal roleNames() As String) End Sub Public Overrides Function RoleExists(ByVal roleName As String) As Boolean Return True End Function End Class End Namespace
//TODO