Imports and exports data from Active Directory using files that store data in the comma-separated value (CSV) format. You can also support batch operations based on the CSV file format standard.
Csvde is a command-line tool that is installed in the %windir%/system32 folder on Windows Server 2003 by default. To run csvde on a computer running Windows Server 2003, open a command prompt, type csvde with the appropriate parameters, and then press ENTER.
You can also run csvde on a computer running Windows XP Professional if you install Active Directory Application Mode (ADAM) on that computer. Csvde will be located in the %windir%/ADAM folder. To download ADAM, see Active Directory Application Mode (ADAM) at the Download Center (http://go.microsoft.com/fwlink/?LinkID=29359).
Csvde [-i ] [-f FileName] [-s ServerName] [-c String1 String2] [-v ] [-j Path] [-t PortNumber] [-d BaseDN] [-r LDAPFilter] [-p Scope] [-l LDAPAttributeList] [-o LDAPAttributeList] [-g ] [-m ] [-n ] [-k ] [-a UserDistinguishedName Password] [-b UserName Domain Password]
| • | You cannot import user passwords by using csvde because passwords must be sent over an encrypted channel. Csvde does not support Secure Sockets Layer (SSL) or encrypted LDAP communication. The previous references to passwords relate to the credentials of the user who is running the csvde command. They are not related to setting passwords for users. |
| • | Applications such as Microsoft Excel are capable of reading and saving data in the CSV format. You can also create CSV files using Notepad; be sure to separate the values that you add to your file with commas. In addition, the Microsoft Exchange Server administration tools are also capable of importing and exporting data using the CSV format, as are many other non-Microsoft tools. The CSV format consists of one or more lines of data, with each value separated by a comma and with no spaces between the comma and the next entry. The first line (sometimes referred to as the header) of the CSV file must contain the names of each attribute in the same order as the data in any line following the first line. For example: CN,FirstName,SurName,Description FirstUserLogonName,1stUserFirstName,1stUserSurname,Manager SecondUserLogonName,2ndUserFirstName,2ndUserSurname,President |
| • | To see a list of properties that can be updated by csvde, see the appropriate supported interfaces in ADSI Objects of LDAP (http://go.microsoft.com/fwlink/?LinkId=91123). For example, to see the properties that can be set for Active Directory user objects, click the IADsUser link (http://go.microsoft.com/fwlink/?LinkId=91124), and then view the Properties table. |
| • | You can use csvde -r to create an LDAP search filter for data export. For example, the following filter exports all users with a particular surname: csvde -r (&(objectClass=User)(sn=Surname)) |
The following sample file contents are for a domain named Cpandl.com that has organizational units (OUs) named SW Dev, Acct, and AP. The AP OU is subordinate to the Acct OU. The first line of the file defines the Active Directory object properties for user accounts to be created by the entries in the rest of the file. The remaining lines are used to create the user accounts. The first user account is created in the default Users container, and the rest of the user accounts are created in the SW Dev, Acct, and AP OUs, respectively:
objectClass,dn,sAMAccountName,userPrincipalName,userAccountControl user,"CN=KMyer,CN=Users,DC=cpandl,DC=com",KenM,KenM@cpandl.com,514 user,"CN=WYu,OU=SW Dev,DC=cpandl,DC=com",WeiY,WeiY@cpandl.com,514 user,"CN=JMorris,OU=Acct,DC=cpandl,DC=com",JonM,JonM@cpandl.com,514 user,"CN=YXu,OU=AP,OU=Acct,DC=cpandl,DC=com",YeX,YeX@cpandl.com,514
| |
Setting userAccountControl to 514 disables the user account. This is recommended because CSVDE cannot set passwords. |
The -d switch indicates the root (top) of a particular query. For example, if you want to export all the objects in the Marketing top-level OU of the Contoso.com domain to a file named marketingobjects.csv, you can use the following command:
csvde -d "ou=marketing,dc=contoso,dc=com" -f marketingobjects.csv
The -r switch is a filter for exporting information from the directory. This switch filters the output that an export request produces. For example, if you want to export only the user account object attributes from a domain to a file named usersonly.csv, you can use the following command:
csvde -r objectClass=user -f usersonly.csv
The following example exports Active Directory data to a file named search.txt, sets the search scope to subtree, and lists the sAMAccountName, CN, and distinguished name attributes for each object that is found in the search:
csvde -f search.txt -p subtree -l SamAccountName,CN,Distinguishname
The following example imports the data from the current domain (the domain that you are logged on to) from a file named input.csv:
csvde -i -f input.csv
The following example exports the data from the current domain (the domain that you are logged on to) to a file named output.csv:
csvde -f output.csv
For additional examples using CSVDE, see article 327620 in the Microsoft Knowledge Base (http://go.microsoft.com/fwlink/?LinkId=91125).
| Format | Meaning |
Italic | Information that you supply |
Bold | Elements that the you type exactly as shown |
Ellipsis (...) | Parameter that can be repeated several times in a command line |
Between brackets ([]) | Optional items |
Between braces ({}); choices separated by pipe (|). Example: {even|odd} | Set of choices from which you choose only one |
Courier font | Code or program output |
| InitWizard("1050686f-3464-41af-b7e4-016ab0c4db261033"); |