Recipe 4.25 Importing Objects Using an LDIF File

4.25.1 Problem

You want to import objects into Active Directory using an LDIF file. The file could contain object additions, modifications, and/or deletions.

4.25.2 Solution

4.25.2.1 Using a command-line interface

To import objects using the ldifde utility, you must first create an LDIF file with the objects to add, modify, or delete. Here is an example LDIF file that adds a user, modifies the user twice, and then deletes the user:

dn: cn=jsmith,cn=users,dc=rallencorp,dc=com changetype: add objectClass: user samaccountname: jsmith sn: JSmith useraccountcontrol: 512 dn: cn=jsmith,cn=users,dc=rallencorp,dc=com changetype: modify add: givenName givenName: Jim - replace: sn sn: Smith - dn: cn=jsmith,cn=users,dc=rallencorp,dc=com changetype: delete

Once you've created the LDIF file, you just need to run the ldifde command to import the new objects.

> ldifde -i -f input.ldf

4.25.3 Discussion

For more information on the LDIF format, check RFC 2849.

4.25.3.1 Using a command-line interface

To import with ldifde, simply specify the -i switch to turn on import mode and -f <filename> for the file. It can also be beneficial to use the -v switch to turn on verbose mode to get more information in case of errors.

4.25.4 See Also

Recipe 4.24 for information on LDIF, RFC 2849 (The LDAP Data Interchange Format (LDIF) Technical Specification), and MS KB 237677 (Using LDIFDE to Import and Export Directory Objects to Active Directory)



Active Directory Cookbook
Active Directory Cookbook, 3rd Edition
ISBN: 0596521103
EAN: 2147483647
Year: 2006
Pages: 456

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net