Author |
Topic: LDAP Command-Line Tool - ldapmodify examples with sample ldif files |
|
eLDAP member offline |
|
posts: |
107 |
joined: |
08/02/2006 |
from: |
Austin, TX |
|
|
|
|
|
LDAP Command-Line Tool - ldapmodify examples with sample ldif files |
Use the command-line tool ldapmodify to modify existing entries. ldapmodify opens a connection to the directory and authenticates the user. Then it opens the LDIF file supplied as an argument and modifies the LDAP entries specified by the file.
ldapmodify uses a modified form of an LDIF file. Within the file itself, you use the attribute changetype to specify the type of change.
Syntax
ldapmodify [options] [-f LDIF-filename]
Example
ldapmodify -h localhost -p 389 -D "uid=testuser" -w password -f changes.ldif
|
|
|
|
|
|
|
eLDAP member offline |
|
posts: |
107 |
joined: |
08/02/2006 |
from: |
Austin, TX |
|
|
|
|
|
Sample ldapmodify LDIF file -- Adding value(s) |
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modify
add: title
title: HR manager
title: Director of operation
title: VP sales
The changetype is classified as modify-add and loading this LDIF file is going to add the values listed to the given attribute title, creating the attribute if necessary.
|
|
|
|
|
|
|
eLDAP member offline |
|
posts: |
107 |
joined: |
08/02/2006 |
from: |
Austin, TX |
|
|
|
|
|
Sample ldapmodify LDIF file -- Deleting value(s) |
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modify
delete: title
title: HR manager
title: Director of operation
The changetype is classified as modify-delete and loading this LDIF file is going to delete the values listed from the given attribute title, removing the entire attribute if all current values of the attribute are listed for deletion.
If no values are listed, as follows:
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modify
delete: title
the entire attribute is going to be removed.
|
|
|
|
|
|
|
eLDAP member offline |
|
posts: |
107 |
joined: |
08/02/2006 |
from: |
Austin, TX |
|
|
|
|
|
Sample ldapmodify LDIF file -- Replacing value(s) |
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modify
replace: title
title: Sales manager
title: VP operation
The changetype is classified as modify-replace and loading this LDIF file is going to replace all exsiting values with the new values listed, creating the attribute if necessary.
If no values are listed, as follows:
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modify
replace: title
the entire attribute is going to be removed.
|
|
|
|
|
|
|
eLDAP member offline |
|
posts: |
107 |
joined: |
08/02/2006 |
from: |
Austin, TX |
|
|
|
|
|
Sample ldapmodify LDIF file -- Renaming an entry |
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modrdn
newrdn: uid=user001
deleteoldrdn: 0
The changetype is classified as modRDN and loading this LDIF file is going to rename the current dn of the entry from "uid=user.01,ou=people,dc=example,dc=com"
to
"uid=user001,ou=people,dc=example,dc=com"
without (0) removing the old rdn uid=user.01 from the entry.
|
|
|
|
|
|
|
eLDAP member offline |
|
posts: |
107 |
joined: |
08/02/2006 |
from: |
Austin, TX |
|
|
|
|
|
Sample ldapmodify LDIF file -- Putting all together (Changes within an entry) |
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modify
add: title
title: HR manager
title: Director of operation
-
delete: mail
mail: user.01@example.com
-
delete: description
-
replace: telephonenumber
telephonenumber: 1-123-555-1234
telephonenumber: 1-123-555-6789
-
delete: description
|
|
|
|
|
|
|
eLDAP member offline |
|
posts: |
107 |
joined: |
08/02/2006 |
from: |
Austin, TX |
|
|
|
|
|
Sample ldapmodify LDIF file -- Putting all together (Changes across entry) |
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modify
add: title
title: HR manager
title: Director of operation
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modify
delete: mail
mail: user.01@example.com
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modify
delete: description
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modify
replace: telephonenumber
telephonenumber: 1-123-555-1234
telephonenumber: 1-123-555-6789
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modify
delete: description
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modify
delete: description
dn: uid=user.01,ou=people,dc=example,dc=com
changetype: modrdn
newrdn: uid=user001
deleteoldrdn: 0
|
|
|
|
|
|
|
|