Link to home
Start Free TrialLog in
Avatar of Netlink2
Netlink2

asked on

Roles.AddUserToRole gives an error " The user 'newUser' is already in role 'Guests' "

When using a standard login control it won't allow me to add a new user, not even "JoeBloggs".
The following is the code:
Roles.AddUserToRole(username, "Guests")

The following is the error:
An exception of type 'System.Configuration.Provider.ProviderException' occurred in System.Web.dll but was not handled in user code
Additional information: The user 'JoeBloggs' is already in role 'Guests'.
SOLUTION
Avatar of RedKelvin
RedKelvin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Netlink2
Netlink2

ASKER

What I did to fix the problem was to delete the login database, recreate it with aspnet_regsql.exe. Then I redid the actual login page from scratch.

I also had to change the web.config file to
  <remove name="LocalSqlServer"/>
  <add name="LocalSqlServer" connectionString="Data Source=Server;Initial Catalog=RealEstate;Persist Security Info=True;User ID=myId;pwd=myPW"/>

I still don't know exactly where the problem was, but removing the connectionstring caused the error to change.