.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

role Provider

Posted By:      Posted Date: October 22, 2010    Points: 0   Category :ASP.Net


we create some code in web.config file to allow or deny the user to view that page

my question is how it work and is there some way to allow or deny user programatic?


View Complete Post

More Related Resource Links

Custom Role Provider Not Authenticating Users

I have created a custom role provider that is hard coded to say everyone is in a certain group (code below).  I have edited the webconfig of Central Admin, my Web Front End, and the Claims Service.  I can sucessuflly log in using the asp.net membership provider and configured access to the site by adding the "custom" role to the Owner Group.  With all of the above items setup I can launch visual studio and attach the to IIS process and verify that my custom role provider is being called.  Even with all this setup I cannot get another forms based user to be able to access the site.  The other user is getting a sharepoint access denied issues. Any Ideas?   public class IdBasedRoleProvider : RoleProvider { public const string AllAuthenticatedUsersRoleName = "custom"; public override string ApplicationName { get; set; } public override string[] GetRolesForUser(string username) { return new[] { AllAuthenticatedUsersRoleName }; } public override bool RoleExists(string roleName) { if (roleName == AllAuthenticatedUsersRoleName) return true; else return false; } #region Methods Not Implemented public override string[] GetAllRoles() { throw new NotImplementedException(); } public override bool IsUserInRole(string username, string roleName) { throw new NotImplementedException(); } public override void Ad

Sharepoint 2007 Custom Role Provider

I have been trying to configure Sharepoint 2007 to use a custom role provider (using Forms based authentication) that we have developed.  I have been following the tutorial at http://www.andrewconnell.com/blog/articles/HowToConfigPublishingSiteWithDualAuthProvidersAndAnonAccess.aspx, so my configuration files look similar (only database connection string changes).   I have the Membership role provider working (able to add users to my site collection) but am not able to figure out what i have done wrong in setting up the role provider.   To verify that our code works, I setup an empty website project and called the asp.net configuation tool (as described in the above reference article) and am able to view/create/remove/etc... roles as expected, so I think the role provider is working correctly.   What is the recommended way to debug my problem?   Thanks Greg.

Same Role provider (ASP.NET Services database) for various WCF services


Hi there,

Service Authetnication

Have configured WCF service to implement authentication using AD(Active Directory), when a request comes from the client it is authenticated aginst active directory and either allow access or deny based on the credentials passed to the service.

Authorization using ASP.NET Role provider

Have implemented the method level authorization using SecurityPermission attribute, which checks the role data in ASP.NET Services database( in other words Membership database) against aspnet_roles, aspnet_Users_InRoles tables to allow / deny access to particular method.

It works well with single instance of service, where the request is from mutliple client applicaitons.

In the above implementation, WCF service is configured to use ASP.NET Membership database to implement authorization to authorize access to particular methods.


Would like to know if it is feasible/best practice to utilise the same instance of ASP.NET Membership databse to implement Role based authorization on number of WCF services.

[PrincipalPermission(SecurityAction.Demand, Role = <

Role Provider mess up Welcome [username] on wss


Hi,I have a role provider, and this is how i wrote for my GetRolesForUser(string username), now the problem is on the wss page, on the top right corner, it shows Welcome "System Account" Instead of the logged in user. And I checked it, after RunWithElevatedPrivilage, The CurrentUser is System Account,How can I make the welcome to show the current logged user?

Thank you

public override string[] GetRolesForUser(string username)
      //string[] s = ws.GetRolesForUser(username);
      //return s;
      List<string> domainGroups = new List<string>();
      var webContext = SPContext.Current.Web;


          using (SPSite site = new SPSite(webContext.Site.ID))
            //siteEval = site.OpenWeb(site.

need help with sharepoint (wss 3.0) with Windows authentication and Custom Role provider

I'm trying to setup sharepoint(wss 3.0) to use my custom role provider with Windows authentication. I've modified the web.config to enable role manager and I am able to select my custom roles when assigning permissions but it doesn't seem like sharepoint is check the permission again my custom roles. If I enable Forms authentication and use my custom membership provider it all works as expected but I do not want to use FBA because of the issues with Client Integration. Essentially I want all the features that comes with the default windows authentications but just have permission be control from my custom role provider. Can anyone offer any solution or suggestions?

Extend Role provider


How can I add my own methods to Custom Role provider apart from the default ones? I need to compile this security dll and be able to call the defined methods in web applications without having to instantiate the custom role provider. 

role provider example


Hello everybody,

I recently received a mail from a asp net cybernaute which ask me how to use role provider with AD, here is my answer:

Le 28/09/2010 17:14, madan535 a écrit :

This email was sent from a user at ASP.NET Forums. Replying
to this email will be sent back to the user via normal

Sent From: madan535
Subject: AD Roles

Hai benoit,

I have also similar requirement. There are different roles in my application

The users needs to logon based on the roles.

How do u achieve this?




Hi Venkat,
For role authentication I use a roleProvider.
My role provider is issued from a book example, here is the link : http://www.editions-eni.fr/Books/aSP-NET-avec-VB-NET-sous-Visual-Studio-2008-Conception-et-developpement-d-applications-Web/.6_3a6222cf-b921-41f5-886c-c989f77ba994_9f7ed5d9-

Authorization Manager (AzMan) as role provider with Windows integrated authentication in SharePoint


Hi all,

First I will describe my environment: Windows Server 2008 R2 x64, IIS 7, SQL Server 2008 and MOSS 2007 Enterprise Edition SP2 x64.

I am trying to setup SharePoint 2007 portal to use Windows integrated authentication with Authorization Manager (AzMan) as role provider.

I have set up an authorization store and defined a set of roles in there. Further I configured the web.configs of my SharePoint environment to use AzMan as role provider.

In IIS I see the roles appearing, but unfortunately those roles are not available in my SharePoint portal. I also see notification in IIS stating that Forms authentication has to be used

What should I do to configure it correctly? Is it even possible to use AzMan with Windows authentication in SharePoint 2007?

Thanks in advance.

With kind regards,




Setting Membership/Profile/Role provider's connection string at runtime...?


How can I set the connection string for the built-in membership, profile and role providers at runtime?

Since each site in our multi-site application uses a separate API to retrieve its specific connection string (via key, for security purposes), I cannot set the connection string to my providers in the web.config file. I need to be able to set the connection strings programmatically at runtime, but I cannot find how to implement this.

I thought many people must have run into this problem, but I can't seem to find anything regarding this.Can anyone here help me with this problem?



Custom Role Provider - Roles.GetRolesForUser(userName) raises exception


Hi All,

We have configured Claims based authentication in our application and We have extented the RoleProvider. When we call the Roles.GetAllRoles() method it returns all the roles available in the aspnet_Roles table. When we call Roles.GetRoleForUser(userName) it raises the following exception.

Exception of type 'System.ArgumentException' was thrown.
Parameter name: encodedValue

   at Microsoft.SharePoint.Administration.Claims.SPClaimEncodingManager.DecodeClaimFromFormsSuffix(String encodedValue)
   at Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvider.GetRolesForUserBestEffort(String username)
   at Microsoft.SharePoint.Administration.Claims.SPClaimsAuthRoleProvider.GetRolesForUser(String username)
   at System.Web.Security.Roles.GetRolesForUser(String username)
   at Dsp.SP.ContentManager.GenericPublishedContent.BindGridPublicGroup(String selectedNode)

When we debug our Custom Role Provider project the breakpoint hits the GetAllRoles() method and it does not hit the GetRolesForUser() method. So we are not sure whether the overridden method is called or not?

Custom Profile Provider and Role - Mysql


May I ask if how can I create a custom mysql profile provider with the following properties?

                <add name="ProjectID" type="Int" defaultValue="0"/>
                <add name="TeamID" type="Int" defaultValue="0"/>
                <add name="EmployeeID" type="String" serializeAs="String"/>
                <add name="LastName" type="String" serializeAs="String"/>
                <add name="FirstName" type="String" serializeAs="String"/>
                <add name="MiddleName" type="String" serializeAs="String"/>
                <add name="NickName" type="String" serializeAs="String"/>

Cusom Role + task provider that wotk with windows and claims identties


I have created a custom principal that is populated with roles from a custom role store (SQL database). I also use a custom SQL Role provider.

I need to implement tasks that are related to a role. These tasks should have a business rule attached to it. For example user's that belong to the Approver role and the batch approval task should only be allowed to approve for amount greater than 1000 and customer x.

I know Azman provides this functionality or NetSQAzman but I can't use it due to my custom authorization should work with both windows and claims identities.

Any ideas? 

Thank you


Membership / Role Provider Problems with Connector NET 6.3.5


I'm building a website using VS2008 Pro, Win XP Pro, MySql 5.1 and Connector 6.3.5. My connection to the database seems to work fine when I attempt to pull data from tables to build pages but when I try to create users for the website using the create user wizard I get the followin error:

Access denied for user ''@'localhost' (using password: NO)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: MySql.Data.MySqlClient.MySqlException: Access denied for user ''@'localhost' (using password: NO)

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[MySqlException (0x80004005): Access

My custom role provider doesn`t work


Hi guys.

Have a little problem. I`ve developed my custom role provider to have my implementation of it logic. But during the process i have a problem with this.

I implemented class CustomRoleProvider:

namespace CSSA
    public class CustomRoleProvider : RoleProvider
        public override string ApplicationName
            get { return "xxx"; }
            set { }

        /// <summary>
        /// Add roles to users.
        /// </summary>
        /// <param name="usernames">list of member which need to accept roles</param>
        /// <param name="roleNames">The list of role, which will be apply to user List</param>
        public override void AddUsersToRoles(string[] usernames, string[] roleNames)
            throw new NotImplementedException();

        public override void CreateRole(string roleName)


        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
            return true;

        public override string[] FindUsersInRole(string roleName, string usernameToMatch)
            throw new NotImplementedException();

        public override string[] GetAllRoles()

Custom role provider and RunWithElevatedPrivileges(recursive loop)


I've implemented custom role provider. i get users from sharepoint list. But i have problem. if user is loged and if i try call method with RunWithElevatedPrivileges, then RunWithElevatedPrivileges cause call of GetRolesForUser. but in GetRolesForUser i use RunWithElevatedPrivileges and this cause new call of GetRolesForUser.... Any one know how can i avoid this recursion? and why RunWithElevatedPrivileges calls GetRolesForUser? i use custom role provider for asp.net site not sharepoint site. Thx

Custom Role Provider Issue In Sharepoint 2010



I have? migrated my existing wsp solution that contains working custom FBA membership and role providers to Sharepoint 2010. As stated in several migration or custom membership provider articles that I fround in Net for Sharepoint 2010, I followed the steps below:

  • Created my FBA login page under _layouts, I inherited it from FormsSignInPage.
  • Set authentication of the web application to Claims
  • Enabled forms based authentication for the application and set my custom provider names.
  • Added provider names to not only my application's web.config but also to central application web.config and securitytoken web service's web.config (which is located in [14 hive]\WebServices\Securitytoken).

The current issue I am having is as follows:

  • When user types in username and password and presses the login button in the FBA login page, yellow "screen of death" :) is displayed indicating: "The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentati

Does the application name property in sql membership provider and role provider has to be the same?



For my FBA authentication I have membership provider application name as 'x' and role provider application name as 'y'.

My FBA login form is authenticating users that belong to application 'x' in aspnetdb database, and not application 'y'.

could anybody help me with this..



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend