By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,574 Members | 1,968 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,574 IT Pros & Developers. It's quick & easy.

Create a database login in the default domain

P: n/a
I'm trying to create a login in the default domain. I know I can pull
this information from xp_loginconfig, but don't see how I can use it in
the context of sp_grantlogin.

For example, pull the domain the user is currently logged in on and
insert it into the sp_grantlogin script. Has anyone ever done this in
the past?

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Aaron" <aa********@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I'm trying to create a login in the default domain. I know I can pull
this information from xp_loginconfig, but don't see how I can use it in
the context of sp_grantlogin.

For example, pull the domain the user is currently logged in on and
insert it into the sp_grantlogin script. Has anyone ever done this in
the past?


First of all, I strongly suggest that you consider adding domain accounts to
a domain group, and then just grant login to the group - that's much easier
to manage (and it's the MS recommended way to implement security).

I'm not sure I really understood your question - do you mean that given the
Windows domain account name 'Someone', you want to find the default domain
name from xp_loginconfig (let's call it SOMEDOMAIN), and then grant login to
'SOMEDOMAIN\Someone'? If so, see the (untested) code below.

If I misunderstood you, you might want to give a specific example of what
you're trying to do.

Simon

create proc dbo.GrantLogin
@Account sysname
as
begin
declare @Domain sysname,
@Login sysname

create table #t
(Attrib sysname, Val sysname)

insert into #t exec master..xp_loginconfig

select @Domain = Val
from #t
where Attrib = 'default domain'

set @Login = @Domain + '\' + @Account

exec sp_grantlogin @Login
end
Jul 23 '05 #2

P: n/a
Great, this seems perfect. Thanks for your help.

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.