Question: How would I extract Active Directory info (Username, first name, surname) and populate an SQL table with the results?

Many thanks

Scott

Answer: 
If you just need it in SQL, I'm using the code below

```
INSERT...
SELECT A.SAMAccountName, A.Mail,  A.displayName  FROM
    (SELECT * FROM OpenQuery(ADSI, 'SELECT title, displayName, sAMAccountName, givenName, telephoneNumber, facsimileTelephoneNumber, sn, userAccountControl,mail  
    FROM ''LDAP://domain.ro/DC=domain,DC=ro'' where objectClass = ''User''')
    WHERE (sn is not null) and (givenName is not null) and (mail is not null) )A

```

where ADSI is a linked server created based on this:
<http://msdn2.microsoft.com/en-us/library/aa772380(VS.85).aspx>
There are different ways to do that. I use PHP to get data out of our Active Directory.Take a look at the chapter "[Lightweight Directory Access Protocol](http://www.php.net/manual/en/book.ldap.php)" in the PHP Documentation. It's also easy to populate a database using PHP, e.g. [MySQL](http://www.php.net/manual/en/book.mysql.php) or [Microsoft SQL Server](http://www.php.net/manual/en/book.mssql.php).