473,385 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

modifying user security

I have an asp page that currently is creating a database and a user
login for that database. After everything successfully (I thought)
executed, I tried to change my connection properties for the server
and then login as this new user. It wouldn't allow me to, so I logged
back in as the administrator and looked at the properties for the new
login. On the general tab, it had the user's default database
specified as the new database that I had created in the asp page, but
when I went to the database access tab, the database was not selected.
So, I'm not sure how to set that in my script. I've done some
searching in BOL, but I can't figure it out. Also, if there's a way
to do this in a query, or stored procedure, will it also specify what
type of role the user has (public, db_owner, etc.)? Thanks.
Jul 20 '05 #1
5 2930
ca********@hotmail.com (geoff) wrote in message news:<bf**************************@posting.google. com>...
I have an asp page that currently is creating a database and a user
login for that database. After everything successfully (I thought)
executed, I tried to change my connection properties for the server
and then login as this new user. It wouldn't allow me to, so I logged
back in as the administrator and looked at the properties for the new
login. On the general tab, it had the user's default database
specified as the new database that I had created in the asp page, but
when I went to the database access tab, the database was not selected.
So, I'm not sure how to set that in my script. I've done some
searching in BOL, but I can't figure it out. Also, if there's a way
to do this in a query, or stored procedure, will it also specify what
type of role the user has (public, db_owner, etc.)? Thanks.


You need to be clear about the difference between a login (allows
access to the server), and a user (allows access to a database). I'm
not sure that I followed your description, but it sounds as if you
have created a new login, however that login has not been granted
access to the database.

In TSQL, you can use sp_grantdbaccess to give the login access to a
database, or you can use the SQLDMO object model from VB or whatever.
Note that granting a login access to a database creates a user, but
doesn't add the user to any roles (eg. db_owner), except for the
public role (all users are in the public role). So you may be looking
for something like this (see BOL for more details of the syntax):

use database NewDB
go
exec sp_grantdbaccess 'NewLogin', 'NewLogin'
exec sp_addrolemember 'db_owner', 'NewLogin'
go

Simon
Jul 20 '05 #2
Thanks Simon, I had found the sp_grantdbaccess stored procedure, but
yes, I was looking for the sp_addrolemember sp also. That all works
fine now. Thanks for your help. Now, another question. Since my UI
lets a user create a database, I also have it set up so that they can
delete a database. When I test it, sometimes it will delete just fine,
but other times, when I run the drop database sp, it tells me it can't
delete the database because it's currently in use. I'm not quite sure
how it's in use since I just created it and there's no way anyone is
connected to it. But, regardless, is it possible to programmatically
shut down the database and then delete it so that the user does not
encounter this error? Thanks again.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

"geoff tyler" <ca********@hotmail.com> wrote in message
news:40*********************@news.frii.net...
Thanks Simon, I had found the sp_grantdbaccess stored procedure, but
yes, I was looking for the sp_addrolemember sp also. That all works
fine now. Thanks for your help. Now, another question. Since my UI
lets a user create a database, I also have it set up so that they can
delete a database. When I test it, sometimes it will delete just fine,
but other times, when I run the drop database sp, it tells me it can't
delete the database because it's currently in use. I'm not quite sure
how it's in use since I just created it and there's no way anyone is
connected to it. But, regardless, is it possible to programmatically
shut down the database and then delete it so that the user does not
encounter this error? Thanks again.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


That depends who is connected - you can use sp_who to find out who is using
the database. Make sure you set your connection's current database context
to master before trying to drop the database, as that avoids the situation
where you are blocking yourself. Apart from that, you can use this command
to 'kick out' other users before dropping it:

alter database MyDB set offline with rollback immediate

Simon
Jul 20 '05 #4
Thanks Simon, but I get an error stating incorrect syntax near the
keyword 'set'. I've done some searching to try to figure it out, but
everything I've come across has the same syntax as what you provided.
Any ideas what I should check? Here's the actual command I was
executing....

alter database newtestdatabase set offline with rollback immediate

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5
Nevermind, I found a stored procedure to use to take it offline and it
worked great. Thanks for the idea.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #6

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

Similar topics

0
by: Gouda Man | last post by:
Hey everyone, I'm embedding the Python interpreter within my program to use as a scripting language. However, one of the unique features of our program is the ability of the internal language to...
6
by: qwweeeit | last post by:
Hi all, when I was young I programmed in an interpreted language that allowed to modify itself. Also Python can (writing and running a module, in-line): fNew =open("newModule.py",'w') lNew=...
2
by: LC's No-Spam Newsreading account | last post by:
I asked a couple of days ago about the following arrangement (simplified). I made some progress using netscape.security.PrivilegeManager.enablePrivilege but still have to ask some further help. ...
1
by: A.M-SG | last post by:
Hi, Can I view/modify SOAP message at the client proxy side without using soap extensions? Thank you,
5
by: Jon Slaughter | last post by:
How can I take a uri passed to a interface script(a script that is called for every page request) modify it, do whatever, and then change the uri that the user see's to be whatever? Essentially...
3
by: Paul | last post by:
Hello All, I am working through the SAMS "ASP.NET 2.0 - Unleased" book to teach myself ASP.NET. It is a great book, but Chapter 21 "Using ASP.NET Membership" is causing me problems - or maybe I...
4
by: =?Utf-8?B?Vm9nZWxlciwgdm9sa2hhcmQ=?= | last post by:
Hello, i want to modify the App-SettingsFile of an CLickOnce-deployed Application with an external Editor (like Notepad.exe etc) . I´ve found the File in some directory (..Apps/2.0/.../) under...
31
by: zdenko | last post by:
I have a multi user database and users were created by user level security wizzard - as I mentioned in message before. Everything works fine for those users, but now I have another problem. I have...
1
by: nimad | last post by:
Hello, I would like to modify the content of the location bar (address bar) using JavaScript. Suppose I am at http://localhost/WebTests/TestEvent.aspx The followig line: window.location =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.