Importing Objects Using an LDIF File

Importing Objects Using an LDIF File


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


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

	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


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

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. The Windows Server 2003 version of ldifde also includes the j switch that will create a logfile for troubleshooting purposes.

See Also

Recipe 4.28 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)

 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows