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

Re: Script for mass updates



using michaël's filter, you could try this:

ldapsearch [options] '(&(ou:dn:=people)(!(ou=system))(!(displayName=*)))' cn | awk '
/^dn:/ {
  print
  print "changetype: modify"
  print "replace: displayName"
  next
}
/^cn:/ {
  sub(/^cn/, "displayName")
}
{ print }
' | ldapmodify [options]

we aren't doing your homework, are we? :-)

regards,
Jephté

2017-02-01 18:50 GMT+04:00 Michael Ströder <michael@stroeder.com>:
Nick Milas wrote:
> Does anyone have a ready-made script (e.g. bash) that would do the following:
>
>  Loop on all entries in the ou=people branch where ou <> "system" {
>    If attribute DisplayName does not exist{
>       Set DisplayName to the value of attibute cn
>   }
>  }

You could use this LDAP filter to retrieve all entries you have to modify and their 'cn'
attribute:

(&(ou:dn:=people)(!(ou=system))(!(displayName=*)))

Applying this simple LDIF to all the entries found is left as exercise to the reader:

dn: cn=dummy,ou=people,dc=example,dc=com
changetype: modify
add: displayName
displayName: <value taken from 'cn'>

Ciao, Michael.





--
Jephté CLAIN | Développeur, Intégrateur d'applications
Service Système d'Information
Direction des Systèmes d'Information
Tél: +262 262 93 86 31 || Gsm: +262 692 29 58 24