Export and Import AD Objects with ldifde
Hallo zusammen,
Eigentlich dachte ich, dass der Export and Import von AD Objekten mit LDIFDE ganz einfach ist. Nun, es gibt da schon ein paar Kniffe die man kennen muss.
Die Parameter von ldifde.exe sind hier beschrieben: http://technet.microsoft.com/en-us/library/cc758935(WS.10).aspx
Zur demonstration, habe ich eine OU "Contacts" mit zwei Kontakten drin.
Der Contact "Lucky Luke" ist Mitglied der Verteilerliste "TestDist"
Export
Nun mache ich den Export mit lidfde. Einmal mit der Option "-m" welches die Systemattribute nicht exportiert.
ldifde.exe -f C:\ldifde\contacts1.txt -d "OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch" -s icesrv02.corp.icewolf.ch -p SubTree
ldifde.exe -f C:\ldifde\contacts2.txt -d "OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch" -s icesrv02.corp.icewolf.ch -p SubTree -m
Contacts1.txt
dn: OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
changetype: add
objectClass: top
objectClass: organizationalUnit
ou: Contacts
distinguishedName: OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
instanceType: 4
whenCreated: 20120128152759.0Z
whenChanged: 20120128152814.0Z
uSNCreated: 4309132
uSNChanged: 4309132
name: Contacts
objectGUID:: KjETVYzouEu58R1zq4zqqA==
objectCategory:
CN=Organizational-Unit,CN=Schema,CN=Configuration,DC=corp,DC=icewolf,DC=ch
dSCorePropagationData: 16010101000000.0Z
dn: CN=Joe Black,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
changetype: add
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: contact
cn: Joe Black
sn: Black
l: GW
title: Vice
postalCode: 3818
physicalDeliveryOfficeName: 011
telephoneNumber: +41
facsimileTelephoneNumber: +41
givenName: Joe
distinguishedName: CN=Joe Black,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
instanceType: 4
whenCreated: 20120128152759.0Z
whenChanged: 20120128152814.0Z
displayName: Joe Black
uSNCreated: 4309133
info: sd
uSNChanged: 4309136
department: SC
company: Comp
proxyAddresses: SMTP:joe.black@internet.com
proxyAddresses: smtp:Joe.Black@icewolf.ch
proxyAddresses: smtp:joeblack@corp.icewolf.ch
streetAddress: street
targetAddress: SMTP:joe.black@internet.com
extensionAttribute1: 1
extensionAttribute2: 2
extensionAttribute3: 3
extensionAttribute4: 4
extensionAttribute5: 5
extensionAttribute6: 6
extensionAttribute7: 7
extensionAttribute8: 8
extensionAttribute9: 9
extensionAttribute10: 10
mailNickname: joeblack
wWWHomePage: www
internetEncoding: 1310720
extensionAttribute11: 11
extensionAttribute12: 12
extensionAttribute13: 13
extensionAttribute14: 14
extensionAttribute15: 15
name: Joe Black
objectGUID:: 1ZnvCizZPk+8jh7RoEuBoQ==
showInAddressBook:
CN=Default Global Address List,CN=All Global Address Lists,CN=Address Lists Co
ntainer,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configurati
on,DC=corp,DC=icewolf,DC=ch
showInAddressBook:
CN=All Contacts,CN=All Address Lists,CN=Address Lists Container,CN=First Organ
ization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=corp,DC=icewolf,
DC=ch
legacyExchangeDN:
/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Re
cipients/cn=Joe Blackd1e
objectCategory: CN=Person,CN=Schema,CN=Configuration,DC=corp,DC=icewolf,DC=ch
dSCorePropagationData: 16010101000000.0Z
mail: joe.black@internet.com
manager: CN=boa,OU=Icewolf Users,DC=corp,DC=icewolf,DC=ch
homePhone: +41
mobile: +41
pager: +41
msExchPoliciesIncluded: {26491cfc-9e50-4857-861b-0cb8df22b5d7}
msExchPoliciesIncluded: f79e9dae-1068-4f9a-825a-8e0093b0f0b3
msExchUMDtmfMap: firstNameLastName:56325225
msExchUMDtmfMap: lastNameFirstName:25225563
msExchUMDtmfMap: emailAddress:56325225
msExchUMDtmfMap: reversedPhone:14+
msExchRecipientDisplayType: 6
msExchVersion: 44220983382016
dn: CN=Luke Lucky,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
changetype: add
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: contact
cn: Luke Lucky
sn: Lucky
givenName: Luke
distinguishedName:
CN=Luke Lucky,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
instanceType: 4
whenCreated: 20120128152800.0Z
whenChanged: 20120128152814.0Z
displayName: Lucky, Luke
uSNCreated: 4309134
memberOf: CN=TestDist,OU=TestOU,DC=corp,DC=icewolf,DC=ch
uSNChanged: 4309134
proxyAddresses: SMTP:lucky@internet.com
proxyAddresses: smtp:Luke.Lucky@icewolf.ch
proxyAddresses: smtp:lukelucky@corp.icewolf.ch
targetAddress: SMTP:lucky@internet.com
mailNickname: lukelucky
internetEncoding: 1310720
name: Luke Lucky
objectGUID:: PqwQqsQdy0GTzQCxBXum5A==
showInAddressBook:
CN=Default Global Address List,CN=All Global Address Lists,CN=Address Lists Co
ntainer,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configurati
on,DC=corp,DC=icewolf,DC=ch
showInAddressBook:
CN=All Contacts,CN=All Address Lists,CN=Address Lists Container,CN=First Organ
ization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=corp,DC=icewolf,
DC=ch
legacyExchangeDN:
/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Re
cipients/cn=Luke Lucky876
objectCategory: CN=Person,CN=Schema,CN=Configuration,DC=corp,DC=icewolf,DC=ch
dSCorePropagationData: 16010101000000.0Z
mail: lucky@internet.com
msExchPoliciesIncluded: {26491cfc-9e50-4857-861b-0cb8df22b5d7}
msExchPoliciesIncluded: f79e9dae-1068-4f9a-825a-8e0093b0f0b3
msExchUMDtmfMap: firstNameLastName:585358259
msExchUMDtmfMap: lastNameFirstName:582595853
msExchUMDtmfMap: emailAddress:58259
msExchRecipientDisplayType: 6
msExchVersion: 44220983382016
Contacts2.txt
dn: OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
changetype: add
distinguishedName: OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
dSCorePropagationData: 16010101000000.0Z
instanceType: 4
name: Contacts
objectCategory:
CN=Organizational-Unit,CN=Schema,CN=Configuration,DC=corp,DC=icewolf,DC=ch
objectClass: top
objectClass: organizationalUnit
ou: Contacts
uSNChanged: 4309132
uSNCreated: 4309132
whenChanged: 20120128152814.0Z
whenCreated: 20120128152759.0Z
dn: CN=Joe Black,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
changetype: add
cn: Joe Black
company: Comp
department: SC
displayName: Joe Black
distinguishedName: CN=Joe Black,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
dSCorePropagationData: 16010101000000.0Z
extensionAttribute1: 1
extensionAttribute10: 10
extensionAttribute11: 11
extensionAttribute12: 12
extensionAttribute13: 13
extensionAttribute14: 14
extensionAttribute15: 15
extensionAttribute2: 2
extensionAttribute3: 3
extensionAttribute4: 4
extensionAttribute5: 5
extensionAttribute6: 6
extensionAttribute7: 7
extensionAttribute8: 8
extensionAttribute9: 9
facsimileTelephoneNumber: +41
givenName: Joe
homePhone: +41
info: sd
instanceType: 4
internetEncoding: 1310720
l: GW
legacyExchangeDN:
/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Re
cipients/cn=Joe Blackd1e
mail: joe.black@internet.com
mailNickname: joeblack
mobile: +41
msExchPoliciesIncluded: {26491cfc-9e50-4857-861b-0cb8df22b5d7}
msExchPoliciesIncluded: f79e9dae-1068-4f9a-825a-8e0093b0f0b3
msExchRecipientDisplayType: 6
msExchUMDtmfMap: firstNameLastName:56325225
msExchUMDtmfMap: lastNameFirstName:25225563
msExchUMDtmfMap: emailAddress:56325225
msExchUMDtmfMap: reversedPhone:14+
msExchVersion: 44220983382016
name: Joe Black
objectCategory: CN=Person,CN=Schema,CN=Configuration,DC=corp,DC=icewolf,DC=ch
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: contact
pager: +41
physicalDeliveryOfficeName: 011
postalCode: 3818
proxyAddresses: SMTP:joe.black@internet.com
proxyAddresses: smtp:Joe.Black@icewolf.ch
proxyAddresses: smtp:joeblack@corp.icewolf.ch
sn: Black
streetAddress: street
targetAddress: SMTP:joe.black@internet.com
telephoneNumber: +41
title: Vice
uSNChanged: 4309136
uSNCreated: 4309133
whenChanged: 20120128152814.0Z
whenCreated: 20120128152759.0Z
wWWHomePage: www
dn: CN=Luke Lucky,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
changetype: add
cn: Luke Lucky
displayName: Lucky, Luke
distinguishedName:
CN=Luke Lucky,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
dSCorePropagationData: 16010101000000.0Z
givenName: Luke
instanceType: 4
internetEncoding: 1310720
legacyExchangeDN:
/o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Re
cipients/cn=Luke Lucky876
mail: lucky@internet.com
mailNickname: lukelucky
msExchPoliciesIncluded: {26491cfc-9e50-4857-861b-0cb8df22b5d7}
msExchPoliciesIncluded: f79e9dae-1068-4f9a-825a-8e0093b0f0b3
msExchRecipientDisplayType: 6
msExchUMDtmfMap: firstNameLastName:585358259
msExchUMDtmfMap: lastNameFirstName:582595853
msExchUMDtmfMap: emailAddress:58259
msExchVersion: 44220983382016
name: Luke Lucky
objectCategory: CN=Person,CN=Schema,CN=Configuration,DC=corp,DC=icewolf,DC=ch
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: contact
proxyAddresses: SMTP:lucky@internet.com
proxyAddresses: smtp:Luke.Lucky@icewolf.ch
proxyAddresses: smtp:lukelucky@corp.icewolf.ch
sn: Lucky
targetAddress: SMTP:lucky@internet.com
uSNChanged: 4309134
uSNCreated: 4309134
whenChanged: 20120128152814.0Z
whenCreated: 20120128152800.0Z
dn: CN=Joe Black,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
changetype: modify
add: showInAddressBook
showInAddressBook:
CN=Default Global Address List,CN=All Global Address Lists,CN=Address Lists Co
ntainer,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configurati
on,DC=corp,DC=icewolf,DC=ch
-
dn: CN=Joe Black,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
changetype: modify
add: showInAddressBook
showInAddressBook:
CN=All Contacts,CN=All Address Lists,CN=Address Lists Container,CN=First Organ
ization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=corp,DC=icewolf,
DC=ch
-
dn: CN=Joe Black,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
changetype: modify
add: manager
manager: CN=boa,OU=Icewolf Users,DC=corp,DC=icewolf,DC=ch
-
dn: CN=Luke Lucky,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
changetype: modify
add: showInAddressBook
showInAddressBook:
CN=Default Global Address List,CN=All Global Address Lists,CN=Address Lists Co
ntainer,CN=First Organization,CN=Microsoft Exchange,CN=Services,CN=Configurati
on,DC=corp,DC=icewolf,DC=ch
-
dn: CN=Luke Lucky,OU=Contacts,OU=TestOU,DC=corp,DC=icewolf,DC=ch
changetype: modify
add: showInAddressBook
showInAddressBook:
CN=All Contacts,CN=All Address Lists,CN=Address Lists Container,CN=First Organ
ization,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=corp,DC=icewolf,
DC=ch
-
Import
Nach dem Löschen der Contacs und der OU versuchen wir nun die Objekte wieder zu importieren.
ldifde.exe -i -f C:\ldifde\contacts1.txt -s icesrv01.corp.icewolf.ch -j C:\ldifde
Tja, das war dann wohl nichts...
Nun versuchen wir es mal mit dem Export ohne die Systemattribute
ldifde.exe -i -f C:\ldifde\contacts1.txt -s icesrv02.corp.icewolf.ch -j C:\ldifde
Der Import hat zwar geklappt, aber die Mitgliedschaft in der Verteilerliste wurde nicht wiederhergestellt, weil das MemberOf nur in der contacts1.txt datei steht.
memberOf: CN=TestDist,OU=TestOU,DC=corp,DC=icewolf,DC=ch
Weitere Informationen:
- http://support.microsoft.com/kb/237677/de
- http://www.msxfaq.de/tools/ldifde.htm
- http://blog.icewolf.ch/archive/2009/11/19/export-active-directory-objects-ldifdecsvde.aspx