Asked by:
user data stored in sql while role data stored in local file???

Question
-
User119957594 posted
I set up my site to store user data on a sql server but when creating roles it creates and uses a local database file.
I use the drag and drop wizard control to create users. But to create roles I either used the web configuration site or the line Roles.CreateRole("name");
Why is it using one datastore for users and another for roles?
thanks
Monday, October 31, 2016 3:31 AM
All replies
-
User535082756 posted
hi
Just a thought. Please check the connection string in the web.config. please refer this article. Hope it helps.
https://www.asp.net/web-forms/overview/older-versions-security/roles/creating-and-managing-roles-cs
<roleManager enabled="true" defaultProvider="SecurityTutorialsSqlRoleProvider"> <providers> <add name="SecurityTutorialsSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" applicationName="SecurityTutorials" connectionStringName="SecurityTutorialsConnectionString" /> </providers> </roleManager>
Thanks,
Monday, October 31, 2016 4:15 AM -
User119957594 posted
This is my entire web config
<?xml version="1.0"?>
< configuration>
<system.web>
<authentication mode ="Forms">
<forms loginUrl="Default.aspx" name=".ASPXFORMSAUTH"></forms>
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken= b03f5f7f11d50a3a"
connectionStringName="conString"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
applicationName="/"
requiresUniqueEmail="true"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""/>
</providers>
</membership>
<authorization>
</authorization>
<roleManager enabled="true" />
<compilation debug="false" targetFramework="4.0" />
<customErrors mode="Off"/>
</system.web>
<connectionStrings>
<add name ="conString"
connectionString ="Data source=DELLXPS\SQLEXPRESS; Initial Catalog=SEIN; Integrated Security=true;"
providerName =" System.Data.Sqlclient"/>
</connectionStrings>
< /configuration>Monday, October 31, 2016 5:30 AM -
User535082756 posted
hi
In your web.config
<roleManager enabled="true" /> replace this line with the below line
<roleManager enabled="true" defaultProvider="sqlRoleManager"> <providers> <clear /> <add name="sqlRoleManager" type="System.Web.Security.SqlRoleProvider" connectionStringName="conString"/> </providers> </roleManager>
Monday, October 31, 2016 6:42 AM -
User119957594 posted
hello. thanks for the help
im not sure im putting this in correctly, im being told that providers is an invalid child element and /rolemanager is expected to be /system.web
If I try putting the role manager tag in the already existing providers tag im told rolemanager is an invalid child element
If I leave it a is but add the default provider to the roleManager tag and add the <add name tag below the one that currently exists, im told the name can not be found.
this is simple stuff I feel like such a noob.
<?xml version="1.0"?> < configuration> <system.web> <authentication mode ="Forms"> <forms loginUrl="Default.aspx" name=".ASPXFORMSAUTH"></forms> </authentication> <membership> <providers> <clear /> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="conString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/> </providers> </membership> <authorization> </authorization> <compilation debug="false" targetFramework="4.0" /> <customErrors mode="Off"/> <roleManager enabled="true" defaultProvider="sqlRoleManager"/> <providers> <!--system.web invalid child element--> <clear /> <add name="sqlRoleManager" type="system.web.security.roleprovider" connectionstringname="conString"/> </providers> </roleManager> <!--</system.web> epxected--> </system.web> <connectionStrings> <add name ="conString" connectionString ="Data source=DELLXPS\SQLEXPRESS; Initial Catalog=SEIN; Integrated Security=true;" providerName =" System.Data.Sqlclient"/> </connectionStrings> < /configuration>
Monday, October 31, 2016 7:13 AM -
User535082756 posted
hi
Can you try this??
<?xml version="1.0"?> <configuration> <system.web> <authentication mode ="Forms"> <forms loginUrl="Default.aspx" name=".ASPXFORMSAUTH"></forms> </authentication> <membership> <providers> <clear /> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="conString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/> <add name="sqlRoleManager" type="system.web.security.roleprovider" connectionstringname="conString"/> </providers> </membership> <authorization> </authorization> <compilation debug="false" targetFramework="4.0" /> <customErrors mode="Off"/> <roleManager enabled="true" defaultProvider="sqlRoleManager"/> <!--<providers> --><!--system.web invalid child element--><!-- <clear /> </providers> </roleManager>--> <!--</system.web> epxected--> </system.web> <connectionStrings> <add name ="conString" connectionString ="Data source=DELLXPS\SQLEXPRESS; Initial Catalog=SEIN; Integrated Security=true;" providerName =" System.Data.Sqlclient"/> </connectionStrings> </configuration>
Monday, October 31, 2016 8:10 AM -
User119957594 posted
"default role provider could not be found" on the rolemanager tag
Monday, October 31, 2016 8:20 AM -
User535082756 posted
hi,
The provider is inside the membership instead it has to be this way.
can you try this?
<?xml version="1.0"?> <configuration> <system.web> <authentication mode ="Forms"> <forms loginUrl="Default.aspx" name=".ASPXFORMSAUTH"></forms> </authentication> <membership> <providers> <clear /> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="conString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/> </providers> </membership> <roleManager enabled="true" defaultProvider ="sqlRoleManager" > <providers> <add name="sqlRoleManager" type="System.Web.Security.SqlRoleProvider" connectionStringName="conString" /> </providers> </roleManager> <authorization> </authorization> <compilation debug="false" targetFramework="4.0" /> <customErrors mode="Off"/> <!--<roleManager enabled="true" defaultProvider="sqlRoleManager"/>--> <!--<providers> --><!--system.web invalid child element--><!-- <clear /> </providers> </roleManager>--> <!--</system.web> epxected--> </system.web> <connectionStrings> <add name ="conString" connectionString ="Data source=DELLXPS\SQLEXPRESS; Initial Catalog=SEIN; Integrated Security=true;" providerName =" System.Data.Sqlclient"/> </connectionStrings> </configuration>
Monday, October 31, 2016 1:37 PM