Please visit DEMANDDRAFT.SHOP for quality of products...

Ad

Search This Blog

Monday, February 1, 2016

How to Query Active Directory Users From SQl Server

SELECT 
    sAMAccountName, 
    userPrincipalName, 
    Name, 
    department, 
    Manager, 
    title, 
    mobile, 
    ipPhone, 
    mail, 
    distinguishedName, 
    streetAddress,
    l, 
    postalCode, 
    co, 
    company

FROM 
    OPENQUERY(ADSI,'<LDAP://servername.local/DC=servername,DC=local>;         (objectClass=user);sAMAccountName,Name,Manager,userPrincipalName,title,ipPhone,mail,mobile,department,distinguishedName,streetAddress,l,postalCode,co,company;subtree')


servername like : MyserverName.local (in my scenario my server name follows 

serverName.local

No comments:

Post a Comment