"Aaron" <aa********@yah oo.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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\Som eone'? 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_logi nconfig
select @Domain = Val
from #t
where Attrib = 'default domain'
set @Login = @Domain + '\' + @Account
exec sp_grantlogin @Login
end