Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Enabling Roles Using a Custom Membership Provider

Reply
Thread Tools

Enabling Roles Using a Custom Membership Provider

 
 
EagleRed@HighFlyingBirds.com
Guest
Posts: n/a
 
      02-08-2006
I have setup a custom membership provider for an ASP.NET 2.0 application as
follows:

<connectionStrings>
<add name="MyDB" connectionString="Data Source=localhost;
user id=myAppLogon;
password=pppwwwddd;Initial Catalog=MyAppDB"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<authentication mode="Forms" />
<membership defaultProvider="myAppProvider">
<providers>
<add name="myAppProvider" connectionStringName="MyDB"
...
type="System.Web.Security.SqlMembershipProvider"/>
</providers>
</membership>
</system.web>

I created MyAppDB using the aspnet_regsql utility and added some tables that
have some relations with the tables it created. All has worked fine to this
point.

I now want to add roles. I went into the WAT and enabled roles. It added a
roleManager line to the web.config file as follows.

<system.web>
<authentication mode="Forms" />
<roleManager enabled="true" />
<membership defaultProvider="myAppProvider">
<providers>
<add name="myAppProvider" connectionStringName="MyDB"
...
type="System.Web.Security.SqlMembershipProvider"/>
</providers>
</membership>
</system.web>

I edited it to read,

<roleManager enabled="true" defaultProvider="myAppProvider" />

I added some roles which did not appear in MyAppDB and I cannot edit or
manager users. The error says it cannot find the provider. What happen? How
can it be fixed?

As always, any help would be appreciated.
 
Reply With Quote
 
 
 
 
Dominick Baier [DevelopMentor]
Guest
Posts: n/a
 
      02-08-2006
Hi,

role and membership are 2 different providers - you also have to register
the role provider - the name "myAppProvider" is unknown to ASP.NET for roles.

look at machine.config in the framework directory for the roleManager element
and copy it to your local web.config (give it an appropriate name, change
the connection string name etc...)

---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com

> I have setup a custom membership provider for an ASP.NET 2.0
> application as follows:
>
> <connectionStrings>
> <add name="MyDB" connectionString="Data Source=localhost;
> user id=myAppLogon;
> password=pppwwwddd;Initial Catalog=MyAppDB"
> providerName="System.Data.SqlClient"/>
> </connectionStrings>
> <system.web>
> <authentication mode="Forms" />
> <membership defaultProvider="myAppProvider">
> <providers>
> <add name="myAppProvider"
> connectionStringName="MyDB"
> ...
>
> type="System.Web.Security.SqlMembershipProvider"/>
> </providers>
> </membership>
> </system.web>
> I created MyAppDB using the aspnet_regsql utility and added some
> tables that have some relations with the tables it created. All has
> worked fine to this point.
>
> I now want to add roles. I went into the WAT and enabled roles. It
> added a roleManager line to the web.config file as follows.
>
> <system.web>
> <authentication mode="Forms" />
> <roleManager enabled="true" />
> <membership defaultProvider="myAppProvider">
> <providers>
> <add name="myAppProvider"
> connectionStringName="MyDB"
> ...
>
> type="System.Web.Security.SqlMembershipProvider"/>
> </providers>
> </membership>
> </system.web>
> I edited it to read,
>
> <roleManager enabled="true" defaultProvider="myAppProvider"
> />
>
> I added some roles which did not appear in MyAppDB and I cannot edit
> or manager users. The error says it cannot find the provider. What
> happen? How can it be fixed?
>
> As always, any help would be appreciated.
>



 
Reply With Quote
 
 
 
 
EagleRed@HighFlyingBirds.com
Guest
Posts: n/a
 
      02-08-2006
Thanks, that cleared it up.

"Dominick Baier [DevelopMentor]" wrote:

> Hi,
>
> role and membership are 2 different providers - you also have to register
> the role provider - the name "myAppProvider" is unknown to ASP.NET for roles.
>
> look at machine.config in the framework directory for the roleManager element
> and copy it to your local web.config (give it an appropriate name, change
> the connection string name etc...)
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
> > I have setup a custom membership provider for an ASP.NET 2.0
> > application as follows:
> >
> > <connectionStrings>
> > <add name="MyDB" connectionString="Data Source=localhost;
> > user id=myAppLogon;
> > password=pppwwwddd;Initial Catalog=MyAppDB"
> > providerName="System.Data.SqlClient"/>
> > </connectionStrings>
> > <system.web>
> > <authentication mode="Forms" />
> > <membership defaultProvider="myAppProvider">
> > <providers>
> > <add name="myAppProvider"
> > connectionStringName="MyDB"
> > ...
> >
> > type="System.Web.Security.SqlMembershipProvider"/>
> > </providers>
> > </membership>
> > </system.web>
> > I created MyAppDB using the aspnet_regsql utility and added some
> > tables that have some relations with the tables it created. All has
> > worked fine to this point.
> >
> > I now want to add roles. I went into the WAT and enabled roles. It
> > added a roleManager line to the web.config file as follows.
> >
> > <system.web>
> > <authentication mode="Forms" />
> > <roleManager enabled="true" />
> > <membership defaultProvider="myAppProvider">
> > <providers>
> > <add name="myAppProvider"
> > connectionStringName="MyDB"
> > ...
> >
> > type="System.Web.Security.SqlMembershipProvider"/>
> > </providers>
> > </membership>
> > </system.web>
> > I edited it to read,
> >
> > <roleManager enabled="true" defaultProvider="myAppProvider"
> > />
> >
> > I added some roles which did not appear in MyAppDB and I cannot edit
> > or manager users. The error says it cannot find the provider. What
> > happen? How can it be fixed?
> >
> > As always, any help would be appreciated.
> >

>
>
>

 
Reply With Quote
 
John Toop
Guest
Posts: n/a
 
      06-05-2009
Hi Dominick, Could I get some details on this? Does this mean that there
needs to be a "provider" entry that corresponds to the "defaultprovider"
defined within the "rolemanager" element? This seems to be where I'm getting
hung up. I'm looking at the what EagleRed was trying to do but they seem to
reference Membership provider and I'm trying to setup a "role" provider.

I see (from machine.config) that there are definitions for two role
providers;

name="AspNetSqlRoleProvider"
name="AspNetWindowsTokenRoleProvider"

But, while I can understand the concept that my custom role provider is not
going to have the same name as a "built in" role provider I do not know what
to enter for the other attributes. My class handles the connection string.
The "type" is the namespace but is a namespace the same as the class? The
word "namespace" does not appear within my vb class. Does the
"applicationName" need to correspond to the "ApplicationName" property of the
RoleProvider defined within the class?

"Dominick Baier [DevelopMentor]" wrote:

> Hi,
>
> role and membership are 2 different providers - you also have to register
> the role provider - the name "myAppProvider" is unknown to ASP.NET for roles.
>
> look at machine.config in the framework directory for the roleManager element
> and copy it to your local web.config (give it an appropriate name, change
> the connection string name etc...)
>
> ---------------------------------------
> Dominick Baier - DevelopMentor
> http://www.leastprivilege.com
>
> > I have setup a custom membership provider for an ASP.NET 2.0
> > application as follows:
> >
> > <connectionStrings>
> > <add name="MyDB" connectionString="Data Source=localhost;
> > user id=myAppLogon;
> > password=pppwwwddd;Initial Catalog=MyAppDB"
> > providerName="System.Data.SqlClient"/>
> > </connectionStrings>
> > <system.web>
> > <authentication mode="Forms" />
> > <membership defaultProvider="myAppProvider">
> > <providers>
> > <add name="myAppProvider"
> > connectionStringName="MyDB"
> > ...
> >
> > type="System.Web.Security.SqlMembershipProvider"/>
> > </providers>
> > </membership>
> > </system.web>
> > I created MyAppDB using the aspnet_regsql utility and added some
> > tables that have some relations with the tables it created. All has
> > worked fine to this point.
> >
> > I now want to add roles. I went into the WAT and enabled roles. It
> > added a roleManager line to the web.config file as follows.
> >
> > <system.web>
> > <authentication mode="Forms" />
> > <roleManager enabled="true" />
> > <membership defaultProvider="myAppProvider">
> > <providers>
> > <add name="myAppProvider"
> > connectionStringName="MyDB"
> > ...
> >
> > type="System.Web.Security.SqlMembershipProvider"/>
> > </providers>
> > </membership>
> > </system.web>
> > I edited it to read,
> >
> > <roleManager enabled="true" defaultProvider="myAppProvider"
> > />
> >
> > I added some roles which did not appear in MyAppDB and I cannot edit
> > or manager users. The error says it cannot find the provider. What
> > happen? How can it be fixed?
> >
> > As always, any help would be appreciated.
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Membership Provider - Custom Error Messages Brett Ossman ASP .Net Security 0 03-11-2009 09:33 PM
Membership or Role Provider // Provider Model // Factories .. How does MS do it? sloan ASP .Net 1 07-03-2007 08:17 PM
Unable to redirect when using custom 'Login' with custom 'Membership provider' asnowfall@gmail.com ASP .Net 0 06-05-2007 05:15 PM
Deploying 2.0 app on a Service Provider .. Membership Provider sloan ASP .Net 5 06-03-2006 11:20 PM
Active Directory Membership provider - can you use roles? =?Utf-8?B?bGFuZW0=?= ASP .Net 0 10-21-2005 01:53 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57