Tips and Tricks

Contacts En Masse

Find out how to import Contacts and User Objects into Active Directory, as well as modify batched objects.

Imagine that your company enters into a great new partnership with another company. Sales will go up, everyone will get raises and all sorts of good things will happen. Oh, and to ease communications between the companies, the boss would like you to add all 1,000 of the other company’s employees to your Active Directory domain as Contacts. Yikes! When does that raise come?

There’s no need to sweat, because AD comes fully equipped for bulk object creation. The easiest way in this scenario would be to use Windows’ built-in support for importing objects from a simple comma-separated values (CSV) file.

You’ll need to get the other company’s employee info into a CSV file. That can be done using Notepad, or even Microsoft Excel, which makes it a bit easier. Set up seven columns so that the first row contains the column names and subsequent rows contain information about one new Contact object per row. The columns you’ll need are:

 ObjectClass. Put “contact” in this column.

 DisplayName. Enter the contact name as you want it to appear in the Global Address List, such as John Doe (Fabrikam).

 DN. You’ll need to specify the distinguished name for the new contact, such as “cn=John Doe,ou=Fabrikam,dc=ourcompany,dc=com” or whatever is appropriate. Note that this allows you to create the Contact objects in a separate organizational unit, if you like.

 MailNickname. This is the contact’s alias and can be up to 64 characters. You might use something like “ext-JohnD.”

 TargetAddress. Here’s where you provide the contact’s real e-mail address. Use something like “SMTP:john. [email protected]” and be sure to include the SMTP: prefix.

 ProxyAddress. This is the user’s e-mail proxy address within your domain, such as “SMTP:[email protected].” E-mail sent to this address will be redirected to the TargetAddress you specify.

 Mail. This is the user’s primary SMTP address; use the same SMTP address you used for ProxyAddress, but omit the SMTP: prefix.

 MsExchPoliciesExcluded. This optional eighth column should contain “{26491CFC-9E50-4857-861B-0CB8DF22B5D7}” if you don’t want Exchange to automatically generate X.400 and other e-mail addresses for the new contact. If you omit this column, Exchange will create the additional addresses.

Batch-Modify AD
You can use the more complex LDAP Data Interchange Format (LDIF), instead of CSV files, if you want to modify AD objects in batches. The file would be used in conjunction with the LDIFDE.EXE command-line tool. For example, you might use LDIFDE to change everyone's business address and phone number after moving the office, or change the “reports to” field for everyone in a particular department after they get a new boss. It's a great way to automate what would otherwise be a tedious manual process. Read about it in Windows’ online help or at www.microsoft.com/
windows2000/techinfo/planning/
activedirectory/bulksteps.asp.

Once you have all of the data in the Excel spreadsheet, save it as a CSV file. Then, from a command line, run the CSVDE utility: csvde –i –f filename.csv. Make sure you’re logged on as a domain administrator or other user that has permission to create the new Contact objects. Watch the utility’s output carefully, as it will warn you if you’re trying to create a new Contact by using a name that’s already in use, or if another error occurs.

About the Author

Don Jones is a multiple-year recipient of Microsoft’s MVP Award, and is Curriculum Director for IT Pro Content for video training company Pluralsight. Don is also a co-founder and President of PowerShell.org, a community dedicated to Microsoft’s Windows PowerShell technology. Don has more than two decades of experience in the IT industry, and specializes in the Microsoft business technology platform. He’s the author of more than 50 technology books, an accomplished IT journalist, and a sought-after speaker and instructor at conferences worldwide. Reach Don on Twitter at @concentratedDon, or on Facebook at Facebook.com/ConcentratedDon.

comments powered by Disqus
Most   Popular