Monday, March 12, 2012

Query Domain Users

How do I retrieve a list of all domain users using a queryAug,
Do you want a list of all users in the domain?
use: exec xp_cmdshell 'net user /DOMAIN'
NOTE: You need to be sysadmin or have exec rights on xp_cmdshell.
For a list of all users in a database use sp_helpuser.
Mark Allison, SQL Server MVP
http://www.markallison.co.uk|||HI
Create Linked Server for Active Directory:
EXEC sp_addlinkedserver
@.server = 'ADSI',
@.srvproduct = 'Active Directory Services 2.5',
@.provider = 'ADSDSOObject',
@.datasrc = 'adsdatasource'
You can use simple selec
eg:
select * from OPENQUERY(ADSI, "select distinguishedName, physicalDeliveryOff
iceName, displayName from 'LDAP://OU=Organizational,OU= Users,DC=vodafone,DC
=hu' where objectCategory = 'Person' and objectClass= 'user' order by sn")
or create view based on openquery.
Warning: the default resultsel limited: on w2k 1000 record and on w2003 1500
record.
If You need increase use the ntdsutil.exe. For more information: <http://support.m
icrosoft.co...kb;EN-US;315071>
JBandi

No comments:

Post a Comment