Showing posts with label directory. Show all posts
Showing posts with label directory. 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, February 9, 2012

Adding Active Directory login (ca vs. samaccount)

I am having some issues adding user logins to SQL Server. When I
search for users in Active Directory from Security->Logins->New Login,
I can search for and add users using the short name (samaccount, ex
domain\abcde). However, when I search for users using their CA name
(ex. domanin\firstname.lastname), the user is not found.

Is there some setting that needs to be activated in SQL Server to see
the CA name as well as the samaccount name, or is this an issue that
must be resolved on the domain controller.

I would appreciate any insight.

Thanks,

MattHi

SQL Server 2000 only understands "domain\abcde" and not abcde@.domain or CA
names.

Sorry, but can't do much about it.

----------
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland

IM: mike@.epprecht.net

MVP Program: http://www.microsoft.com/mvp

Blog: http://www.msmvps.com/epprecht/

"mattsh" <matt_sh2001@.yahoo.com> wrote in message
news:1116503684.651798.63340@.g43g2000cwa.googlegro ups.com...
>I am having some issues adding user logins to SQL Server. When I
> search for users in Active Directory from Security->Logins->New Login,
> I can search for and add users using the short name (samaccount, ex
> domain\abcde). However, when I search for users using their CA name
> (ex. domanin\firstname.lastname), the user is not found.
> Is there some setting that needs to be activated in SQL Server to see
> the CA name as well as the samaccount name, or is this an issue that
> must be resolved on the domain controller.
> I would appreciate any insight.
> Thanks,
> Matt|||OK, but for some people (like myself) my "long name", say
domain\firstname.lastname (what I believe is our CA name) shows up. My
short name domain\ablastname (what I believe is the samaccount name)
can also be chosen as a login. But for other people, the only thing
that I can access is the domain\cdlastname user name. The
domain\firstname.lastname does not show up when I do a search from SQL
Server.

If it works for me, I figure it should work for others. I just can't
figure out what I need to do so I can add others "long name" (CA).

Thanks again,

Matt