473,405 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Why is this not working - please check my code - Role, Profile

Hello guys,

I have set the MEMBERSHIP, ROLEMANAGER and PROFILE in my config file as
below.

I just want to use my own sql server 2000 table instead of MSDB.

I have used the ASP.net Configruation Page to add couple of users

and roles and then assigned the users to roles.

The membership is working fine it connects to my database. However the
Rolemanager and the Profile is not working.

For roles I test like this:

Dim rls() As String

rls = Roles.GetAllRoles

For ctr As Integer = 0 To rls.Length - 1

Response.Write(rls(ctr))

Next

Even I do:

If User.IsInRole("Admin") Then

Response.Write("Yes")

End If

But it doesn't work.

For Profile when I type Profile and then (.), it shows all the other details
of the Profile object but not the customised properties I have added.

Any input will be much appreciated. Many thanks

Config file

<?xml version="1.0"?>

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

<connectionStrings>

<add name="NorthwindConnectionString" connectionString="Data
Source=MYPC;Initial Catalog=Northwind;User ID=SA"

providerName="System.Data.SqlClient" />

</connectionStrings>

<appSettings/>

<system.web>

<authentication mode="Forms">

<forms loginUrl="LOGIN.aspx">

</forms>

</authentication>

<!--

Don't allow the annonymous users and not logged ins

-->

<authorization>

<deny users="?" />

</authorization>

<!--

used by membership provider

-->

<membership defaultProvider="CustomizedProvider">

<providers>

<add name="CustomizedProvider"

type="System.Web.Security.SqlMembershipProvider"

connectionStringName="NorthwindConnectionString"

applicationName="MembershipAndRoleCustomised"

minRequiredPasswordLength="5"

minRequiredNonalphanumericCharacters="0" />

</providers>

</membership>

<!--

used by role provider

-->

<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">

<providers>

<add name="CustomizedRoleProvider"

type="System.Web.Security.SqlRoleProvider"

applicationName ="MembershipAndRoleCustomised"

connectionStringName="NorthwindConnectionString" />

</providers>

</roleManager>

<!--

used by Profile

-->

<profile defaultProvider="CustomProfileProvider" enabled="true">

<providers>

<add name="CustomizedRoleProvider"

type="System.Web.Security.SqlProfileProvider"

applicationName="MembershipAndRoleCustomised"

connectionStringName="NorthwindConnectionString" />

</providers>

<!-- Define the properties for Profile... -->

<properties>

<add name="HomepageUrl" type="String" serializeAs="String"
allowAnonymous="true" />

<group name="Bio">

<add name="BirthDate" type="DateTime" serializeAs="Xml"
allowAnonymous="true" />

<add name="Location" type="String" allowAnonymous="true"/>

</group>

</properties>

</profile>

<compilation debug="true" strict="false" explicit="true"/>

<pages>

<namespaces>

<clear/>

<add namespace="System"/>

<add namespace="System.Collections"/>

<add namespace="System.Collections.Specialized"/>

<add namespace="System.Configuration"/>

<add namespace="System.Text"/>

<add namespace="System.Text.RegularExpressions"/>

<add namespace="System.Web"/>

<add namespace="System.Web.Caching"/>

<add namespace="System.Web.SessionState"/>

<add namespace="System.Web.Security"/>

<add namespace="System.Web.Profile"/>

<add namespace="System.Web.UI"/>

<add namespace="System.Web.UI.WebControls"/>

<add namespace="System.Web.UI.WebControls.WebParts"/>

<add namespace="System.Web.UI.HtmlControls"/>

</namespaces>

</pages>

</system.web>

</configuration>


Mar 5 '07 #1
2 2731
Couple things, first the profiles. Are you using the Web Application
Project? That's the project that was added to VS as an independent add-in,
and then as part of SP 1. The Web Application Project is different from the
Web Site Project in that it compiles everything into a single dll at build.
The Web Site Project did things dynamically, which meant that the profile
classes were created on the fly when the site was visited. Unfortunately,
this doesn't work with the Web Application Project type. There's an add-in
though that can generate the classes for you so they can be compiled into
your app at: http://workspaces.gotdotnet.com/AspWebProfileGenerator

With luck, that will solve a lot of those issues.

Now, the roles. Keep in mind that User.IsInRole simply tests a cookie to see
if that role is there. Try instead the Roles.IsUserInRole("Admin") or
Roles.IsUserInRole(Page.User.Identity.Name,"Admin" )
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Annie" <my**************@gmail.comwrote in message
news:45******@dnews.tpgi.com.au...
Hello guys,

I have set the MEMBERSHIP, ROLEMANAGER and PROFILE in my config file as
below.

I just want to use my own sql server 2000 table instead of MSDB.

I have used the ASP.net Configruation Page to add couple of users

and roles and then assigned the users to roles.

The membership is working fine it connects to my database. However the
Rolemanager and the Profile is not working.

For roles I test like this:

Dim rls() As String

rls = Roles.GetAllRoles

For ctr As Integer = 0 To rls.Length - 1

Response.Write(rls(ctr))

Next

Even I do:

If User.IsInRole("Admin") Then

Response.Write("Yes")

End If

But it doesn't work.

For Profile when I type Profile and then (.), it shows all the other
details of the Profile object but not the customised properties I have
added.

Any input will be much appreciated. Many thanks

Config file

<?xml version="1.0"?>

<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

<connectionStrings>

<add name="NorthwindConnectionString" connectionString="Data
Source=MYPC;Initial Catalog=Northwind;User ID=SA"

providerName="System.Data.SqlClient" />

</connectionStrings>

<appSettings/>

<system.web>

<authentication mode="Forms">

<forms loginUrl="LOGIN.aspx">

</forms>

</authentication>

<!--

Don't allow the annonymous users and not logged ins

-->

<authorization>

<deny users="?" />

</authorization>

<!--

used by membership provider

-->

<membership defaultProvider="CustomizedProvider">

<providers>

<add name="CustomizedProvider"

type="System.Web.Security.SqlMembershipProvider"

connectionStringName="NorthwindConnectionString"

applicationName="MembershipAndRoleCustomised"

minRequiredPasswordLength="5"

minRequiredNonalphanumericCharacters="0" />

</providers>

</membership>

<!--

used by role provider

-->

<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">

<providers>

<add name="CustomizedRoleProvider"

type="System.Web.Security.SqlRoleProvider"

applicationName ="MembershipAndRoleCustomised"

connectionStringName="NorthwindConnectionString" />

</providers>

</roleManager>

<!--

used by Profile

-->

<profile defaultProvider="CustomProfileProvider" enabled="true">

<providers>

<add name="CustomizedRoleProvider"

type="System.Web.Security.SqlProfileProvider"

applicationName="MembershipAndRoleCustomised"

connectionStringName="NorthwindConnectionString" />

</providers>

<!-- Define the properties for Profile... -->

<properties>

<add name="HomepageUrl" type="String" serializeAs="String"
allowAnonymous="true" />

<group name="Bio">

<add name="BirthDate" type="DateTime" serializeAs="Xml"
allowAnonymous="true" />

<add name="Location" type="String" allowAnonymous="true"/>

</group>

</properties>

</profile>

<compilation debug="true" strict="false" explicit="true"/>

<pages>

<namespaces>

<clear/>

<add namespace="System"/>

<add namespace="System.Collections"/>

<add namespace="System.Collections.Specialized"/>

<add namespace="System.Configuration"/>

<add namespace="System.Text"/>

<add namespace="System.Text.RegularExpressions"/>

<add namespace="System.Web"/>

<add namespace="System.Web.Caching"/>

<add namespace="System.Web.SessionState"/>

<add namespace="System.Web.Security"/>

<add namespace="System.Web.Profile"/>

<add namespace="System.Web.UI"/>

<add namespace="System.Web.UI.WebControls"/>

<add namespace="System.Web.UI.WebControls.WebParts"/>

<add namespace="System.Web.UI.HtmlControls"/>

</namespaces>

</pages>

</system.web>

</configuration>


Mar 5 '07 #2
Dear Mark,

Yes you are right. I am using the web application project.
I will try to download the add in and install it and hope it will work.

In regarding to RoleManager I am trying to do it as:

Dim rls() As String

rls = Roles.GetAllRoles

For ctr As Integer = 0 To rls.Length - 1

Response.Write(rls(ctr))

Next

Even this one doesn't work ... ie I am using the object model for the Roles.
Could it be affected by the web project too?

many thanks

"Mark Fitzpatrick" <ma******@fitzme.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Couple things, first the profiles. Are you using the Web Application
Project? That's the project that was added to VS as an independent add-in,
and then as part of SP 1. The Web Application Project is different from
the Web Site Project in that it compiles everything into a single dll at
build. The Web Site Project did things dynamically, which meant that the
profile classes were created on the fly when the site was visited.
Unfortunately, this doesn't work with the Web Application Project type.
There's an add-in though that can generate the classes for you so they can
be compiled into your app at:
http://workspaces.gotdotnet.com/AspWebProfileGenerator

With luck, that will solve a lot of those issues.

Now, the roles. Keep in mind that User.IsInRole simply tests a cookie to
see if that role is there. Try instead the Roles.IsUserInRole("Admin") or
Roles.IsUserInRole(Page.User.Identity.Name,"Admin" )
--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Annie" <my**************@gmail.comwrote in message
news:45******@dnews.tpgi.com.au...
>Hello guys,

I have set the MEMBERSHIP, ROLEMANAGER and PROFILE in my config file as
below.

I just want to use my own sql server 2000 table instead of MSDB.

I have used the ASP.net Configruation Page to add couple of users

and roles and then assigned the users to roles.

The membership is working fine it connects to my database. However the
Rolemanager and the Profile is not working.

For roles I test like this:

Dim rls() As String

rls = Roles.GetAllRoles

For ctr As Integer = 0 To rls.Length - 1

Response.Write(rls(ctr))

Next

Even I do:

If User.IsInRole("Admin") Then

Response.Write("Yes")

End If

But it doesn't work.

For Profile when I type Profile and then (.), it shows all the other
details of the Profile object but not the customised properties I have
added.

Any input will be much appreciated. Many thanks

Config file

<?xml version="1.0"?>

<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

<connectionStrings>

<add name="NorthwindConnectionString" connectionString="Data
Source=MYPC;Initial Catalog=Northwind;User ID=SA"

providerName="System.Data.SqlClient" />

</connectionStrings>

<appSettings/>

<system.web>

<authentication mode="Forms">

<forms loginUrl="LOGIN.aspx">

</forms>

</authentication>

<!--

Don't allow the annonymous users and not logged ins

-->

<authorization>

<deny users="?" />

</authorization>

<!--

used by membership provider

-->

<membership defaultProvider="CustomizedProvider">

<providers>

<add name="CustomizedProvider"

type="System.Web.Security.SqlMembershipProvider"

connectionStringName="NorthwindConnectionString"

applicationName="MembershipAndRoleCustomised"

minRequiredPasswordLength="5"

minRequiredNonalphanumericCharacters="0" />

</providers>

</membership>

<!--

used by role provider

-->

<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">

<providers>

<add name="CustomizedRoleProvider"

type="System.Web.Security.SqlRoleProvider"

applicationName ="MembershipAndRoleCustomised"

connectionStringName="NorthwindConnectionString" />

</providers>

</roleManager>

<!--

used by Profile

-->

<profile defaultProvider="CustomProfileProvider" enabled="true">

<providers>

<add name="CustomizedRoleProvider"

type="System.Web.Security.SqlProfileProvider"

applicationName="MembershipAndRoleCustomised"

connectionStringName="NorthwindConnectionString" />

</providers>

<!-- Define the properties for Profile... -->

<properties>

<add name="HomepageUrl" type="String" serializeAs="String"
allowAnonymous="true" />

<group name="Bio">

<add name="BirthDate" type="DateTime" serializeAs="Xml"
allowAnonymous="true" />

<add name="Location" type="String" allowAnonymous="true"/>

</group>

</properties>

</profile>

<compilation debug="true" strict="false" explicit="true"/>

<pages>

<namespaces>

<clear/>

<add namespace="System"/>

<add namespace="System.Collections"/>

<add namespace="System.Collections.Specialized"/>

<add namespace="System.Configuration"/>

<add namespace="System.Text"/>

<add namespace="System.Text.RegularExpressions"/>

<add namespace="System.Web"/>

<add namespace="System.Web.Caching"/>

<add namespace="System.Web.SessionState"/>

<add namespace="System.Web.Security"/>

<add namespace="System.Web.Profile"/>

<add namespace="System.Web.UI"/>

<add namespace="System.Web.UI.WebControls"/>

<add namespace="System.Web.UI.WebControls.WebParts"/>

<add namespace="System.Web.UI.HtmlControls"/>

</namespaces>

</pages>

</system.web>

</configuration>



Mar 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Testor | last post by:
I am writing a simple perl script to learn in the process. The script is supposed to grab a receipt number from the query-string and write it into a file. To do that, here's what I did: ...
8
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link,...
2
by: Chris Michael | last post by:
Hello everybody, Newbie here. I've been working on this for the last two days and I can't figure out where this problem is. I think it's something so obvious, but I can't see it! OK, firstly...
8
by: Sandy | last post by:
Hello - This code was snagged by me from the Internet and altered. Its purpose is to check for swear words. It works the way it currently is, but I need it to be more generic -- i.e., I don't...
11
by: Nurit N | last post by:
This is the third newsgroup that I'm posting my problem. I'm sorry for the multiple posts but the matter becoming urgent. I hope this is the right place for it... I have created a very...
1
by: Liming | last post by:
Hello, I'm a newbie to .NET 2.0 framework from Java, so please bear with me. Is there a way to do a generic Provider model or if anyone knows a product out there that does this? I know .NET...
3
by: Snt | last post by:
Hi! I am trying to get AJAX working on multiple browsers and am having a problem with Firefox. I have the following code: function handleState3(){ switch(http.readyState) { case 0: //...
8
by: AZNewsh | last post by:
System.InvalidOperationException was caught Message="A from address must be specified." Public Shared Sub sendEmail(ByVal fromAddy As String, ByVal toAddy As String, ByVal subject As String,...
3
by: shapper | last post by:
Hello, I have two tables: Polls and Options: Poll PollID, Question Options OptionID, PollID, Answer I want to select a Poll given its ID and all Options associated to it. Options should...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.