Results 1 to 3 of 3

Thread: Implement a custom membership provider

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    259

    Implement a custom membership provider

    I am working on a web based "document server" site for local users who are already using a windows application with SQL Server controling logins and roles. Since the database for the windows application already stores user names, passwords and user roles I am going to leverage all that in my doc server.

    Currently I have the custom username/password authentication working and am now trying to implement Roles for directory security. I have read enough threads from this forum to know I need to implement a custom membership provider but I am not sure how to wire it all up.

    So at this point I have the web.config set to use roles
    Code:
       <system.web>
            <authorization>
                <allow roles="District Manager" />
                <deny users="*" />
            </authorization>
        </system.web>
    And I have a stored procedure that authenticates a user with a boolean (dr.hasrows) and a stored procedure that pulls the role back to the page. However so far I haven't been able to figure out how to combine the login authentication with setting the role in one step. And when I do how to store and use the role as needed.

    I think I have two things to work out. 1) is to change my Authentication scheme from a boolean function into a sub that sets the authentication to true and the user role with variables. And then 2) make ASP.Net work with a custom provider instead of the built in membership.

    Is my thinking correct here or am I missing something? Any pointers to help me on using my own Roles with ASP's Allow Roles function?

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Implement a custom membership provider

    You need to make your Role Provider custom class. Have it inherit from the ProviderBase and in there you'll be able to specify what method returns what.

    There's a more specific example from MSDN for this
    http://msdn.microsoft.com/en-us/libr...74(VS.80).aspx

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Implement a custom membership provider

    To do #2, you will need to specify, in your configuration file, the class and assembly name of your role provider class. It would look something like this

    Code:
    <roleManager enabled="true">
        <providers>
            <clear />
            <add applicationName="/" 
                connectionStringName="TrustSecurity" 
                name="AspNetSqlRoleProvider" 
                type="System.Web.Security.SqlRoleProvider" />
        </providers>
    </roleManager>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width