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
<sectionGroup name="security">
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectionGroup name="authentication">
<section name="anonymousAuthentication" type="any"/>
<section name="windowsAuthentication" type="any"/>
<add name="ConnectionString" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;Connect Timeout=30"
providerName="System.Data.SqlClient" />
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"/>
<authentication mode="Forms">
<forms name=".ASPXFORMSDEMO" loginUrl="login.aspx"
protection="All" path="/" timeout="30" />
<compilation debug="true" targetFramework="4.7.1" />
<httpRuntime targetFramework="4.7.1" />
<allow users="?" />
<roleManager defaultProvider="SqlProvider"
cookieProtection="All" >
<clear />
applicationName="/" />
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, 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=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
<smtp deliveryMethod="SpecifiedPickupDirectory">
**" />

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