Export and Import users/groups and OU in AD Server 2008 using LDIFDE command.
*** All the below commands are use in
command prompt.
Viewing LDIFDE general parameters
Click
Start, point to Programs, point to Accessories, and then click 1. Command
Prompt.
Using LDIFDE to import and export
directory objects to Active Directory
To Export All OU:-
C:\>ldifde -f
orissa.ldf -s WIN-MB9FF6Z1KLE -d "dc=testbed,dc=com" -p subtree -r
"(objectCategory=organizationalUnit)" -l
"cn,objectclass,ou"
Connecting
to "WIN-MB9FF6Z1KLE"
Logging in
as current user using SSPI
Exporting
directory to file orissa.ldf
Searching
for entries...
Writing out
entries......
6 entries
exported
The command
has completed successfully
To Import All OU Expect Default OU:-
Edit the orissa.ldf and delete all default OUs.
And use the command.
C:\>ldifde -i -f
orissa.ldf
Connecting
to "WIN-MB9FF6Z1KLE.testbed.com"
Logging in
as current user using SSPI
Importing
directory from file "orissa.ldf"
Loading
entries.....
4 entries
modified successfully.
The command
has completed successfully
To Export all users of a OU:-
C:\>ldifde -f
orissa-bbsr.ldf -s WIN-MB9FF6Z1KLE -d
"ou=bbsr,ou=orissa,dc=testbed,dc=com" -p subtree -r
"(&(objectCategory=person)(objectClass=User)(givenname=*))" -l
"cn,givenName,objectclass,samAccountName"
Connecting
to "WIN-MB9FF6Z1KLE"
Logging in
as current user using SSPI
Exporting
directory to file orissa-bbsr.ldf
Searching
for entries...
Writing out
entries....
4 entries
exported
The command
has completed successfully
Imp users to OU:-
C:\>ldifde -i -f
orissa-bbsr.ldf
Connecting
to "WIN-MB9FF6Z1KLE.testbed.com"
Logging in
as current user using SSPI
Importing
directory from file "orissa-bbsr.ldf"
Loading
entries...
4 entries
modified successfully.
The command
has completed successfully
To Delete a user:-
1-create a
file like c:\deluser.ldf
2-edit the
filr c:\deluser.ldf
3- add the
following
dn:
CN=bbsr1,OU=bbsr,OU=orissa,DC=testbed,DC=com
changetype:
delete
4- run the
command below in cmd prompt
C:\>ldifde -i -f
deluser.ldf -s WIN-MB9FF6Z1KLE
or
C:\>ldifde -i -f
deluser.ldf
Connecting
to "WIN-MB9FF6Z1KLE.testbed.com"
Logging in
as current user using SSPI
Importing
directory from file "deluser.ldf"
Loading
entries..
1 entry
modified successfully.
The command
has completed successfully
export all groups of DC:-
C:\>ldifde -f
ExportGroup.ldf -s WIN-MB9FF6Z1KLE -d "dc=testbed,dc=com" -p subtree
-r
"(&(objectCategory=group)(objectClass=group))"
-l "cn,givenName,objectclass,member,memberof,managedby"
Connecting
to "WIN-MB9FF6Z1KLE"
Logging in
as current user using SSPI
Exporting
directory to file ExportGroup.ldf
Searching
for entries...
Writing out
entries......................................
38 entries
exported
The command
has completed successfully
But these groups can not be imported.
Because it contains all default groups with custom groups. To use this delete
all default groups and use the ldf file.
Export groups from a particular OU :-
C:\>ldifde -f
ExportGroupHwh.ldf -s WIN-MB9FF6Z1KLE -d "OU=salt,OU=hwh,dc=testbed,
dc=com" -p subtree -r
"(&(objectCategory=group)(objectClass=group))" -l
"cn,givenName,objectclass,member,memberof,managedby"
Connecting
to "WIN-MB9FF6Z1KLE"
Logging in
as current user using SSPI
Exporting
directory to file ExportGroupHwh.ldf
Searching
for entries...
Writing out
entries.
1 entries
exported
The command
has completed successfully
Imp groups from a particular OU :-
C:\>ldifde -i -f
ExportGroupHwh.ldf
Connecting
to "WIN-MB9FF6Z1KLE.testbed.com"
Logging in
as current user using SSPI
Importing
directory from file "ExportGroupHwh.ldf"
Loading
entries..
1 entry
modified successfully.
The command
has completed successfully
Comments
Post a Comment