How to get all roles/tasks/operations for one user

Topics: General Topic
May 13, 2012 at 1:50 AM

Hi Andrea,

I am trying to pass in a username and get all its roles or tasks or operations that he is allowed to perform.

I have been using the following but no its not working:

NetSqlAzMan.Providers.NetSqlAzManRoleProvider provider = new NetSqlAzMan.Providers.NetSqlAzManRoleProvider();

string []roles = provider.GetRolesForUser(user);

It seems that the "provider" is always null.

Here is the web.config setup:

    <add name="NetSqlAzManRoleProvider" connectionString="Data Source=MYSERVER;Initial Catalog=NetSqlAzManStorage;Integrated Security=SSPI" providerName="System.Data.SqlClient"/>

    <identity impersonate="false"/>
    <authentication mode="Windows"/>
      <deny users="?"/>
      <allow users="*"/>
    <compilation debug="true" targetFramework="4.0" />

    <roleManager defaultProvider="NetSqlAzManRoleProvider" enabled="true" cacheRolesInCookie="false" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">
        connectionStringName="NetSqlAzManRoleProvider" storeName="My Store" applicationName="My Application" userLookupType="LDAP" defaultDomain="" UseWCFCacheService="False" />
May 14, 2012 at 6:24 AM

Try this:

NetSqlAzMan.Providers.NetSqlAzManRoleProvider provider = ((NetSqlAzManRoleProvider)Roles.Provider);

Andrea Ferendeles
NetSqlAzMan Project Coordinator
E-mail Web

May 14, 2012 at 6:20 PM

The purpose of the Provider pattern is to achieve Transparency. You don't need initialize the provider, ASP.Net will do it.

Just call  


No initialization needed. And you have a list of functions to use.



May 17, 2012 at 1:10 PM


Both answers work just fine.