Showing posts with label authentication. Show all posts
Showing posts with label authentication. Show all posts

Thursday, March 22, 2012

Adding Users to MSDE

I am having a authentication problem.. users log into my website... I authenticate them against Active Directory.. and then I try to query a MSDE database... my connection string is as follows:


Dim connectionString As String = "server='srv_sql'; user id='sa'; password='MyPassword'; Database='MyDB'"
Dim dbConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)

However since I have


<identity impersonate=true>

in my web.config file... it tries to login to the MSDE database as the user.. not as the user SA.

I cannot change the web.config file, since I need that for the active directory authentication to work...

in SQL Server you can add users to a database through the enterprise manager.. how can I do a similar thing using MSDE ?

Is it even possible? or do I have to upgrade to a full SQL instance?

any help would be appreciatedTo answer your question, use the osql command line utility. See this KB article for more info:HOW TO: Manage the SQL Server Desktop Engine (MSDE 2000) by Using the Osql Utility.

what you need to do is use the sp_grantlogin system sp to add the login:

EXEC sp_grantlogin 'Corporate\Test'

Then give it access like this:

EXEC sp_grantdbaccess 'Corporate\BobJ', 'Bob'

You'll also need to give it permissions.

That said, there may need to be adjustments for use with Active Directory.

BUT, you should never, ever, NEVER use the sa login for database access. Not for any app and certainly not for an ASP.NET app. You're opening yourself up to a whole lot of hurt doing it this way. Instead, create a login that has only the specific permissions needed to run the app. No more.

It's more work, but you'll have made the app far more secure.

Don|||...for sure don't use SA on the page itself. What about permissioning the database with Windows authenticated logins since you are using AD...if you haven't already. If you do then you can set windows authentication via Internet Services Manager on the directory hosting the page (be sure to get rid of anonymous users)

Thursday, March 8, 2012

Adding numerous login via script

Hi,

Can anyone point me in the direction of a script that incorporates sp_addlogin, which allows for adding 200 sql authentication logins from an excel spreadsheet, or a temporary sql table with the id info, containing the username, password, and def db?

I'm trying to avoid adding each new login one by one.

EXEC sp_addlogin 'username', 'password', 'default database'Thanks, BPH

A simple approach is to create an expression in your Excel spreadsheet that builds the Exec sp_addlogin line. Copy the formula down to all the rows, then copy/paste the value into Query Analyzer.

If you have loaded the columns into a database table, you can execute a Select statement that builds the lines. Again, copy and paste the results and execute them. Assume you have built a table call logintemp with username, pwd, and dbase columns:

Select 'Exec sp_addlogin ''' + username + ''', ''' + pwd + ''', ''' + dbase + ''''

From logintemp

You need to double the quote marks to yield a quote in the output string.

|||Thanks. I'll give that a shot.

Thursday, February 9, 2012

Adding a Windows Authentication Login to the server from third-party softwareHi,

I have an application in development into which I want to port some simple user management functionality. I have no problem getting lists of users/database roles/etc. and assigning users to roles as seeing fit, but one last function I cannot perform: replicating the "select windows user" dialog in the domain context of the server so that I have a user to add.

Is this possible with smo? or should I just give up on this angle and just attempt to use ActiveDirectory objects on the client machine and hope that the domain context is the same between the client and the sql server?Hi,

this one is not exposed from SMO, its done through the object picker wrapper:

http://dotnet.org.za/armand/articles/2453.aspx

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

Adding a Windows Authentication Login to the server from third-party software

I have an application in development into which I want to port some simple user management functionality. I have no problem getting lists of users/database roles/etc. and assigning users to roles as seeing fit, but one last function I cannot perform: replicating the "select windows user" dialog in the domain context of the server so that I have a user to add.

Is this possible with smo? or should I just give up on this angle and just attempt to use ActiveDirectory objects on the client machine and hope that the domain context is the same between the client and the sql server?Hi,

this one is not exposed from SMO, its done through the object picker wrapper:

http://dotnet.org.za/armand/articles/2453.aspx

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de