aspnetdb problem, user instances expected

R

R.A.M.

Hello,
I have created ASP.NET application with aspnetdb database. In the following
codeI have an error:
System.Security.Principal.IPrincipal user = HttpContext.Current.User;

if (user.IsInRole("Manager")) // HERE ERROR

The error is:

Generating user instances in SQL Server is disabled. Use sp_configure 'user
instances enabled' to generate user instances.

Executing

sp_configure 'user instances enabled'

on aspnetdb database doesn't help (still the same error).
Here is connection string to aspnetdb:
<add name="SqlServices" connectionString="Data
Source=.\SQLEXPRESS;AttachDBFileName=|DataDirectory|\aspnetdb.mdf;Integrated
Security=True" providerName="System.Data.SqlClient"/>

Please help. I have little experience.
/RAM/
 
N

Norman Yuan

It is likely your SQL Server Express installation did not enable "User
Instance". You could enable it, if you REALLY need it and Know what it is.
Chances are you DO NOT need to use User Instance in a web application,
especially if you do not know what User Instance is. read more on SQL Server
book onlne to understance User Instance, and then change your
ConnectionString accordingly if you decide not to use User Instance (then
you need to know more abount ASP.NET security confuguration, such as whicu
user account is running the ASP.NET and how to impersonate if necessary.
 
R

R.A.M.

Uzytkownik "Norman Yuan said:
It is likely your SQL Server Express installation did not enable "User
Instance". You could enable it, if you REALLY need it and Know what it is.
Chances are you DO NOT need to use User Instance in a web application,
especially if you do not know what User Instance is.

I do not want to use User Instance in my application.
My problem is that I don't know why .NET expects User Instance, why the
error occurs. I didn't set User Instance=True in a connection string, so I
don't understand why the error occurs.
Do you know why? How to correct my application?
Coud you help me please?
/RAM/
 
R

R.A.M.

Maybe I incorrectly get the user logged in. In a line:
System.Security.Principal.IPrincipal user = HttpContext.Current.User;
I wanted to get the currently logged in user. I have defined user 'demo' in
aspnetdb and a few roles ('Manager', for instance). I use forms
authentication with login page (asp:Login control).
In a line:
if (user.IsInRole("Manager"))
I wanted to check whether currently logged in user is a manager.
Maybe using HttpContext.Current.User is not a good idea. (I have problems
with reading Books Online because my English is not perfect).
Do you know how to obtain current user logged in? ('demo', for example)?
/RAM/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top