Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Creating Users and mapping to roles

Author  Topic 

anuradhay
Starting Member

41 Posts

Posted - 2005-05-25 : 01:33:11
Hi,

I have generated a script of all the users and roles of a database and then i dropped the database.

Then i created the database again and ran this script. now i am facing a problem. all the users are created using the sp_grantdbaccess proc generated by the script. but when it tries to map some users to a role it is saying that user or role does not exsist. actually those users are not there in the script.

I wonder how come the users are added to the sp_addrolemember when there are no such users.. now how can i rectify this problem.. how can i add these users to the specific roles? is there any way to do this?

Thanks

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-05-25 : 01:41:49
just to clarify:
1. you created a script
2. tried sp_grantdbaccess to each user and it worked
3. when you tried to execute sp_addrolemember , it tells you the role is not there?
- did you execute sp_addrole to create the role first before adding members?


--------------------
keeping it simple...
Go to Top of Page

anuradhay
Starting Member

41 Posts

Posted - 2005-05-25 : 01:48:04
I have also created the roles.. when it tries to map the user with the roles it is throwing the error.. actually the role is there but the user it is trying to map to that role is not there..
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-05-25 : 03:07:08
quote:
Originally posted by anuradhay

I have also created the roles.. when it tries to map the user with the roles it is throwing the error.. actually the role is there but the user it is trying to map to that role is not there..



but the script you created, will create the user and grant access to the database first?

or probably you need to identify which is the role and which is the member?
exec sp_addrolemember @rolename='rolename',@membername='user'


--------------------
keeping it simple...
Go to Top of Page

anuradhay
Starting Member

41 Posts

Posted - 2005-05-25 : 05:26:58
Yes. The script that is generated creats the users first then grant access to the users and then creats roles and then map users to that role..
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2005-05-25 : 05:34:18
and where you able to verify that the users and roles have been created?

if all else fails, try to add the member to the role specifying which is the role and which is the member



--------------------
keeping it simple...
Go to Top of Page
   

- Advertisement -