question

Gloops-5441 avatar image
0 Votes"
Gloops-5441 asked Gloops-5441 edited

Role manager in WebForms authentication database locked

Hello everybody,
It seems I arrived at the good place to ask a question about webforms ?
I am OK with classic authentication with Membership, and manually created an admin role in the tables. Only the admin can access the admin page, that is OK.

But now, I have a problem with the admin page.

It can get the list of users, but not the list of roles, because of a problem with the authentication database which appears to be locked.

The database was created in the data folder, by the CreateUser control. So, as you guess, it is a file database named aspnetdb.mdf.

I also created a database on the server with aspnet_regsql, but I am pretty sure it is not used.

As you can guess with what I said, I have a listbox of users, that is loaded during the Page_Load by :

          this.lbxUsers.DataSource = Membership.GetAllUsers();

And that displays the lists of users, quite OK.

But after that, if I try to load a list of roles with this

lbxRoles.DataSource = Roles.GetAllRoles();

then I have an SqlException (0x80131904)

Cannot open database "D:\PROJECTS VISUAL STUDIO\WEB\FROUFROU\FROUFROU\APP_DATA\ASPNETDB.MDF" requested by the login. The login failed.

Login failed for user 'UC00007\admin'.

That can happen if I opened the database with SSMS, or with the server explorer in Visual Studio (Community 2019), or if I create a Dataset on the database.

Well, I paid attention, all of that seems to be closed.

Do you think I forgot another way to open the database ?

I should have guessed that the Roles manager and the Membership manager share the same connection ?
Is there a particular parameter to give to obtain that ?

It is very strange, the roles is not such a rare feature, I presume ?

So I repeat, once I seized an admin role in the roles table, and I seize somebody in aspnet_usersinrole, that works : only the admin accesses the admin page after I put the correct attributes on the folders. in web.config.

The problem is to be able to modify the roles table on the page.

I have spent a few years without touching to WebForms, and I should have guessed there is nothing special to do so that the roles manager accesses the database from the page_load, and that seems naive.


I am pretty sure someone is able to tell me what I forgot.



Hum, perhaps I forgot to give you the main web.config :

<?xml version="1.0"?>
<!--
Pour plus d'informations sur la configuration de votre application ASP.NET, visitez
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<sectionGroup name="security">
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="authentication">
<section name="anonymousAuthentication" type="any"/>
<!--overrideModeDefault="Allow"-->
<section name="windowsAuthentication" type="any"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;Connect Timeout=30"
providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
</appSettings>
<system.web>
<authentication mode="Forms">
<forms name=".ASPXFORMSDEMO" loginUrl="login.aspx"
protection="All" path="/" timeout="30" />
</authentication>
<compilation debug="true" targetFramework="4.7.1" />
<httpRuntime targetFramework="4.7.1" />
<authorization>
<allow users="?" />
</authorization>
<roleManager defaultProvider="SqlProvider"
enabled="true"
cacheRolesInCookie="true"
cookieName=".ASPROLES"
cookieTimeout="30"
cookiePath="/"
cookieRequireSSL="true"
cookieSlidingExpiration="true"
cookieProtection="All" >
<providers>
<clear />
<add
name="SqlProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="ConnectionString"
applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
</compilers>
</system.codedom>
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<network
clientDomain="mail.net-c.com"
host="mail.net-c.com"
port="993"
userName="@inmano.com"
password="
**" />
<specifiedPickupDirectory
pickupDirectoryLocation="C:\Temp\Mail\"/>
</smtp>
</mailSettings>
</system.net>
</configuration>



dotnet-aspnet-webforms
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers