A
Annie
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>
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>