472,334 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,334 software developers and data experts.

cannot add windows user, cannot delete sql user

We were using sql authentication on our sql server 2000 servers, But
need to use windows authentication. I have an sql user jdoe that owns
many different objects in multiple databases. I have tried adding the
windows login of jdoe with the exact same permissions as the sql user
jdoe, but it complains because it says jdoe already exists. So I
attempt to delete the sql user of jdoe (remembering the permissions so
I can reapply them to the windows user soon to be created) But it says
"you cannot drop the selected login id because that login id owns
objects in one or more databases" So now I am trying to figure out how
to change the ownership of those many many objects in the many
databases from jdoe to dbo so I can delete this sql user of jdoe. Does
anyone know of a way to convert an sql login to a windows login? Or if
that can't be done, how to change the owner of many objects to dbo so I
can delete this user? Maybe a T-SQL script or stored procedure. There
is a stored procedure called sp_changeobjectowner but that only works
for one object, how would I do that on all the objects that jdoe owns?
As you can see I am a newbie but I appreciate any help you can
provide!!! Thanks in advance!

Jul 23 '05 #1
3 9375

"tbone" <to**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
We were using sql authentication on our sql server 2000 servers, But
need to use windows authentication. I have an sql user jdoe that owns
many different objects in multiple databases. I have tried adding the
windows login of jdoe with the exact same permissions as the sql user
jdoe, but it complains because it says jdoe already exists. So I
attempt to delete the sql user of jdoe (remembering the permissions so
I can reapply them to the windows user soon to be created) But it says
"you cannot drop the selected login id because that login id owns
objects in one or more databases" So now I am trying to figure out how
to change the ownership of those many many objects in the many
databases from jdoe to dbo so I can delete this sql user of jdoe. Does
anyone know of a way to convert an sql login to a windows login? Or if
that can't be done, how to change the owner of many objects to dbo so I
can delete this user? Maybe a T-SQL script or stored procedure. There
is a stored procedure called sp_changeobjectowner but that only works
for one object, how would I do that on all the objects that jdoe owns?
As you can see I am a newbie but I appreciate any help you can
provide!!! Thanks in advance!


First, change the owner of all jdoe's objects to dbo - one way is to execute
the output of a query like this one:

select 'exec sp_changeobjectowner ''' + name + ''', ''dbo'''
from sysobjects
where uid = user_id('jdoe')

Then drop the jdoe database user and login, create the new login for the
Windows account, and give it database access. If you want the new user to
own the objects again, then just do a quick find and replace on the original
script to change 'dbo' to 'jdoe' or 'MyDomain\jdoe' or whatever the database
user name is.

Simon
Jul 23 '05 #2
Then drop the jdoe database user and login, create the new login for the
Windows account, and give it database access. If you want the new user
to
own the objects again, then just do a quick find and replace on the
original
script to change 'dbo' to 'jdoe' or 'MyDomain\jdoe' or whatever the
database
user name is.
After I change the ownership to dbo, all the objects in the database
will be dbo now, I guess I can change those objects to a temp user so I
can distinguish them from the rest of the dbo objects. Anyway, is there
any way i could do this by changing the uid mappings or something? Each
database has a user that links to a login correct? Is there a way to
link the already existing user to the new windows login?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3
t bone (bi*********@yahoo.com) writes:
After I change the ownership to dbo, all the objects in the database
will be dbo now, I guess I can change those objects to a temp user so I
can distinguish them from the rest of the dbo objects. Anyway, is there
any way i could do this by changing the uid mappings or something? Each
database has a user that links to a login correct? Is there a way to
link the already existing user to the new windows login?


Don't think so. I was about to suggest trying sp_change_users_login, but I
see in Books Online that it doesn't work for Windows logins.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Phil Powell | last post by:
print_r(is_file("$logPath/$logFileName")); // RETURNS 1 unlink("$logPath/$logFileName"); // RETURNS WARNING: PERMISSION DENIED This code should...
0
by: Ola Ogunneye | last post by:
--=_075912CF.F899D547 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hello again all, I have created an account...
2
by: Dipak Patel | last post by:
Platform: Win2000 SP3, SQL 7.00 - 7.00.1063 I have a SQL-authenticated user with the following permissions: "Process Administrators" server role...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 ...
3
by: Steven Fox | last post by:
============================================================ About DB2 Administration Tools Environment...
4
by: sea | last post by:
I have a database in Access 2002 but I am unable to view code or write any modules when logged in with a limited user account using Windows XP,...
0
by: pankajprakash | last post by:
Hi all I am using the Ajax control toolkit and want to the fill the gridview but at the time of rendering it occurs the error...
2
by: SCPOS | last post by:
Cannot delete X: It is being used by another person or program. Close any programs that might be using the file and try again. Of course I have...
17
by: mandanarchi | last post by:
Access 2003; PC with Windows XP; SBS 2003 I tried searching the forums but it came up with a blank page. I searched Google and found an answer;...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.