[Date Prev][Date Next] [Chronological] [Thread] [Top]

答复: Simple question on ldapmodify command



> 
> Hello,
> I have a simple question on ldapmodify command.
> Assuming that the situation in LDAP is:
> dn: cn=Barbara Jensen, o=University of Michigan, c=US
> objectClass: person
> nickname: Babs
> nickname: Mary
> nickname: Baby
> 

Hmmm, You'd better adjust your entries here.so for "Barbara Jensen", She will has 3 different nickname? Quite confused, don't you think so?

> Assuming that the file /tmp/entrymods exists and has the contents:
> dn: cn=Barbara Jensen, o=University of Michigan, c=US
> changetype: modify
> delete: nickname
> 
> Using ldapmodify -f /tmp/entrymods all the nicknames will be deleted.

Of course. See, the DN entry will uniquely identify a entry in the LDAP database, as the DN equal to Distinguish Name. So in your case, of course this modify action will delete the entry whose DN is "cn=Barbara Jensen, o=University of Michigan, c=US". 

> If I want to delete only "nickname: Mary", how can i do ?
> Is the only solutions re-add "nickname: Babs" and "nickname: 
> Baby" after the 
> deletion?
> 

I think you misunderstand LDAP somehow. I think your original idea is has 3 entry in LDAP database, w/ different nickname, Babs, Mary and Baby. which refer to 3 different person, do you? If so, you must has 3 entry w/ different dn as following:

 dn: cn=Barbara Jensen, o=University of Michigan, c=US
 objectClass: person
 nickname: Babs

 dn: cn=Mary Jensen, o=University of Michigan, c=US
 objectClass: person
 nickname: Mary

 dn: cn=Baby Jensen, o=University of Michigan, c=US
 objectClass: person
 nickname: Baby

>Using ldapmodify -f /tmp/entrymods all the nicknames will be deleted.
>If I want to delete only "nickname: Mary", how can i do ?

Then at this time, when you want to delete the entry whose nickname is Mary, your file's content should looks like this:
dn: cn=Mary Jensen, o=University of Michigan, c=US
changetype: modify
delete: nickname

>Is the only solutions re-add "nickname: Babs" and "nickname: Baby" after the 
deletion?
Nope, since nickname Babs, Mary and Baby is just attribute of the entry which DN is that "Barbara....". and you just delete the whole entry.