Logins from AD to SQL table

  • Does anyone know a way to extract names from Active Directory into a sql table? Using a package, script, etc.

  • USE [master]

    GO

    sp_configure 'show advanced options',1

    GO

    reconfigure with override

    GO

    sp_configure 'Ad Hoc Distributed Queries',1

    GO

    reconfigure with override

    GO

    SELECT Name,displayName,givenname,sn,telephoneNumber,mobile,mail,distinguishedName,SAMAccountName,'description'

    FROM

    OPENROWSET('ADSDSOObject','adsdatasource' ,

    'SELECT Name, displayName,givenname,sn,distinguishedName,

    SAMAccountName,mail,mobile,telephoneNumber,description

    FROM ''LDAP:// DC.domain.com/OU= ,OU=,DC=''

    WHERE objectClass = ''user''')

    !!!! limit 1000 users!!!!

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply