Hello,
Im using the 'xp_cmdshell' to know all users that belong to the local
administrators group and i'm using the 'net use localgroup' to get the outpu
t
into my report.
Here is the code and the Output:
set nocount on
exec xp_cmdshell 'net use localgroup'
go
set nocount off
OUTPUT:
output
Alias name administrators
Comment Administrators have..
NULL
Members
NULL
--
Administrator
DOMAINXXX\Domain Admins
DOMAINXXX\usera
DOMAINXXX\userb
The command completed successfully.
NULL
NULL
Is there any way to avoid lines where appear:
output
--
Alias name administrators
Comment Administrators have..
NULL
and all the information that is not part of the group membership?
Do you know other way to get this information?
Thanks,
Best regardsIf the builtin\administrators group still has a login in SQL
Server (it is by default but you could remove it),
you can get the members of the local admin group with:
EXEC xp_logininfo 'BUILTIN\Administrators', 'MEMBERS'
Another would be using openquery with ADSI:
INFO: Performing a SQL Distributed Query by Using ADSI
http://support.microsoft.com/?id=299410
-Sue
On Fri, 11 Feb 2005 09:53:03 -0800, "CC&JM"
<CCJM@.discussions.microsoft.com> wrote:
>Hello,
>Im using the 'xp_cmdshell' to know all users that belong to the local
>administrators group and i'm using the 'net use localgroup' to get the outp
ut
>into my report.
>Here is the code and the Output:
>set nocount on
>exec xp_cmdshell 'net use localgroup'
>go
>set nocount off
>OUTPUT:
>output
>
>--
>Alias name administrators
>Comment Administrators have..
>NULL
>Members
>NULL
>--
> Administrator
> DOMAINXXX\Domain Admins
> DOMAINXXX\usera
> DOMAINXXX\userb
>The command completed successfully.
>NULL
>NULL
>Is there any way to avoid lines where appear:
>output
>--
>Alias name administrators
>Comment Administrators have..
>NULL
>and all the information that is not part of the group membership?
>Do you know other way to get this information?
>Thanks,
>Best regards
>
Sunday, February 19, 2012
Get OS Group membership
Labels:
belong,
database,
group,
localadministrators,
membership,
microsoft,
mysql,
net,
oracle,
server,
sql,
users,
xp_cmdshell
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment