Profile

Monday 6 June 2011

Querying Active Directory and export data

A friend of mine who is a System Administrator for a office of few hundred users. One of  a task is print out a company phone list from time to time. Sys Admin and HR manager used to walk around everyone's desk to get the phone extension number, then compile a total employee name and phone list on a spreadsheet. They are looking for a easy way to do this task.

First of all everyone in a office should enter his/her contact information into the Global Address List (GAL) Sys Admin already spend lots of time to manage everyone's email address, distribution list, email alias, mailbox size...mean while everyone in office has phone extension number, personal or company's blackberry number,  and they might have a i phone too, and they might change numbers later on. or they might move to different cubicles thus phone list need to update again....

Therefore, it is better for users to manage their own contact information in GAL. Microsoft has the utility called GALMOD so user can edit only his/her own contact information in GAL. Visit this site to download GALMOD:
  http://support.microsoft.com/kb/242223  

Activity Directory can store more data than just user login name and password. After users contacts are updated through GALMOD, administrator can pull information or statistic figure by querying AD. To build and export a company phone list is only one of the many things AD query can do:

Build a query

    * Open Active Directory Users and Computer
    * Select Saved Queries -> New -> Query
    * Give a name to your query
    * Select the root that contains all your users (be careful not to get computers as well)
    * Select Include sub containers if required
    * Build a query string -  the simplest is Users -> Name -> Has a value
    * The Windows MMC has a option to save the query as .xml file, so it can be reused later on.

Export the data

    * Right click in the data section, select View -> Add/Remove Columns
    * Select 3 columns in the order of username, email, fullname e.g.
          o Make sure you remove the default columns
    * Right click in the data section, select Export List ..
    * Enter a file name
    * Change Save as type: to _Text (Comma Delimited)(*.csv)