2

I am trying to write a script that finds the checks homefolder quotas, and sends emails to users who are exceeding a certain percentage of their quota, we have 389 ldap server, I can search the ldap for a uid, and the result is in ldif format. I can not figure out how to read the value of the attribute corresponding to email, lets say personalEmail: hisEmail I want to read the value of the personalEmail attribute, i.e. hisEmail

thanks

Judy
  • 31
  • 2
  • 3
  • dn: uid=jtom,ou=staff,ou=People,dc=xx,dc=com objectClass: top objectClass: xxPerson objectClass: posixAccount objectClass: xxPerson objectClass: inetOrgPerson objectClass: organizationalPerson objectClass: person uid: jtom uidNumber: 2525 cn: jtom gidNumber: 1212 homeDirectory: /homes/jtom givenName: john sn: tom personalEmail: john_tom mailStop: 5555 personalURI: NULL description: 0 xxPersonLocalPhone: +1 232 323 3232 loginShell: /bin/tcsh – Judy Mar 25 '11 at 15:14
  • sorry for that, but seems the line separators were not included there, this is a sample of the output of the ldapsearch – Judy Mar 25 '11 at 15:15
  • if you want shell script for Unix/linux, you'll get better response by adding tags bash. If for Windows (not certain) .bat or .wsh ? Also you may be able to edit your original post to include the data. Paste in your sample data, highlight it, then from the format options just outside on the top of the input form, select the {} (code), this should keep the sample data on separate lines. – shellter Mar 25 '11 at 15:41

1 Answers1

5
ldapsearch ... | awk -F ": " '$1 == "desiredAttribute" {print $2}'
glenn jackman
  • 238,783
  • 38
  • 220
  • 352