.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

My custom role provider doesn`t work

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

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()

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.

Custom field type - set value doesn't work when field is hidden

Hi, I have a simple custom field type which gets a value from the Property Bag and sets that value to a label. This works fine as long as the field is set to Optional (the field is a site column and is part of a site content type), but if I set it to Hidden, the value doesn't get set. public override void UpdateFieldValueInItem()         {             this.EnsureChildControls();               if (this.ControlMode == SPControlMode.New)             {                 this.Value = GetChosenConsole();             }         }   Does anyone know why this is and what I need to do in order for it to work even though it's hidden? Thanks!

Custom Web Part doesn't work with in anonymous access

Hi there, I have a custom webpart in a farm solution deployed to my site. Anonymous users should be able to view the site, however they can't because they are required to login due to the custom web part. If i remove the webpart from the page, anonymous users can view the site perfectly without the need to login. There is nothing really special about the webpart. It's a visual web part which uses the site and it's web data to display a sort of menu. Any idea? Thx in advance! Brecht

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?

WPF Custom Control template doesn't work



I've created a WPF custom control that goes in a DLL and I'm trying to use the control in another project.  Everything works fine except for the part of getting the control template to work. I should get an Orange background as defined below but the control just shows empty in the XAML editor and in runtime.

The code is as follows:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;

namespace MyCustomControl
    public class CustomCtrl : System.Windows.Controls.Control
        public static readonly System.Windows.DependencyProperty ValueProperty;
        public string Value
            get { return (string)GetValue(CustomCtrl.ValueProperty); }
            set { SetValue(CustomCtrl.ValueProperty, value); }

        static CustomCtrl()

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"/>

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

Custom Control Design-Time SiteMap Provider Error


Greetings - I was referred here by MSDN forums hope this is the right place -  

I have a custom control (:WebControl) that renders web.sitemap in a specific way. While it runs error free and produces the expected result, at Design-Time it complains

Error Creating Control - MyControl  The provider 'AspNetXmlSiteMapProvider' specified for the defaultProvider does not exist in the providers collection.

I have discovered that the error is cause by this line of code:

string div = string.Format("<div class='{0}' id='{1}'>{2}</div>", this.CssClass, this.ID.ToString(), EnumerateNodesRecursive(SiteMap.RootNode, level));

or more specifically, by the reference to SiteMap.RootNode - I am not clear what is missing thoough because I have configured the SiteMapProvider in web.config as this:

        <add name="AspNetXmlSiteMapProvider" 
             type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 

Fuzz Testing: Create a Custom Test Interface Provider for Team System


Dan Griffin shows the extensibility of Visual Studio 2005 Team Edition for Software Testers by discussing the modification of the existing Test Interface Provider sample in the latest Visual Studio SDK and implements Fuzz Testing.

Dan Griffin

MSDN Magazine November 2007

ADO.NET: Building a Custom Data Provider for Use with the .NET Data Access Framework


The System.Data.dll assembly in the .NET Framework contains namespaces whose base classes can be used to create custom data providers. These namespaces also define a number of data access interfaces and base classes that let developers create data providers that will interoperate with other custom providers. Using the ADO.NET classes Connection, Command, DataReader, and DataAdapter, writing a provider is easier than writing one for OLE DB. This article explains these classes and their implementation, and how they can be used to write a variety of different kinds of data providers.

Bob Beauchemin

MSDN Magazine December 2001

When I use 'publish', site doesn't work when i post data


Arrgghh, I am so tired of dealing with stuff like this

I've got a project, when I put up on another server I point two sites in IIS6 to it

i have

http://www.main.com  pointing to the folder the files are in


http://www.anotherofoursites.com/main pointing to that same folder in it's own "Virtual Application" or whatever IIS calls it when you put a folder into it's own 

If I just "Build" and push all the files up.. both work without issue and as expected...  but when I use "Publish" to precompile, the site works until I post, and then i get nailed with:

Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Ajax Asyncfileupload doesn't work as soon as I put it in a control


Hi guys,

I can't get my <ajax:asyncfileupload> working and I don't see why...

When outside any panel or table it is working well, but as soon as I put it in a <asp:panel> or table I get a strange error which seems to be on client-side but I don't understand what's happen here. Here is the code and code-behind and Javascript.

Here's the error: 


Here's my front-code:

<%@ Page Language="VB" MasterPageFile="~/masterpages/mpSqueletton.master" AutoEventWireup="false" CodeFile="frmAdmGestSocietes.aspx.vb" Inherits="adm_frmAdmGestSocietes" title="Untitled Page" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphHead" Runat="Server">
<script type="text/javascript" language="javascript">    
        function uploadError(sender,args)
          document.getElementById("<%= lblStatus.ClientID %>").innerText = args.get_fileName(), "<span style='color:red;'>" + args.get_errorMes

AsyncPostBackTrigger doesn't work on server..


 I am new to asp.net and ajax. I have a problem while using update panel.
I have a tabcontainer with 3-4 tab panels. Inside one tab panel there is a cancel button. What i want to do is to when i hit cancel button in code behind i change active tab index to 0 so that tabcontainer shows first tab panel. I have update panel around tab container. This works at my localhost. But on server its behavior is very random. Sometimes it works sometime it doesn't. Unfortunately I am not able to debug it also. I don't know how to debug code on server. As on localhost it works correctly so I am kind of stuck. 
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