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

Many thanks

Scott

Answer: 
The way we do this for a **LARGE** AD environment:

1. Nightly batch process that runs [AdFind](http://www.joeware.net/freetools/tools/adfind/) (freeware tool) to execute an LDAP query and dump it out to CSV files
2. [BCP](http://msdn.microsoft.com/en-us/library/ms162802(v=SQL.90).aspx) (built-in SQL command line tool) to bulk import the CSV files into import tables in the SQL database
3. Stored procedure (executed with [osql](http://msdn.microsoft.com/en-us/library/aa214012(v=sql.80).aspx)) to take the data from the import table and add/update records in the main tables

We pull 145k users, 80k groups, 130k computers from 10 domains in about 2 hours from start to finish. This includes pulling accurate LastLogon information for the users and computers which requires you to hit each domain controller. Without that, the process takes about 30 minutes.
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).