[SAC] LDAP emails

[ re-sent, with correct recipient address for sac ]

I've setup an experimental SVN commit hook for PostGIS that sends
changes
to a mailing list using as the "From" an email address derived
from the committer username.

This is currently done by looking up a file that PostGIS includes
in its repository (authors.svn) but I was wondering if the lookup
could instead be performed directly to the LDAP database.

If that's possible, the commit hook script could be made generic
enough to be usable by any OSGeo hosted SVN repo (I know both
GDAL and GRASS have a commit mailing list, for example)

Does anyone know if it is ?

--strk;

On Mon, Oct 19, 2015 at 11:05:32AM +0200, Sandro Santilli wrote:

This is currently done by looking up a file that PostGIS includes
in its repository (authors.svn) but I was wondering if the lookup
could instead be performed directly to the LDAP database.

tracsvn: 2:17:01 ~> /usr/bin/ldapsearch -H ldaps://ldap.osgeo.org/ -b dc=osgeo,dc=org -x uid=strk mail | awk '/^mail/ {print $2}'

  Martin.
--
Unix _IS_ user friendly - it's just selective about who its friends are !
--------------------------------------------------------------------------

On Mon, Oct 19, 2015 at 11:17:45AM +0200, Martin Spott wrote:

On Mon, Oct 19, 2015 at 11:05:32AM +0200, Sandro Santilli wrote:

> This is currently done by looking up a file that PostGIS includes
> in its repository (authors.svn) but I was wondering if the lookup
> could instead be performed directly to the LDAP database.

tracsvn: 2:17:01 ~> /usr/bin/ldapsearch -H ldaps://ldap.osgeo.org/ -b dc=osgeo,dc=org -x uid=strk mail | awk '/^mail/ {print $2}'

Thanks ! That approach is now in place, let's see how it goes

--strk;

On Mon, Oct 19, 2015 at 11:17:45AM +0200, Martin Spott wrote:

tracsvn: 2:17:01 ~> [...]

Maybe refine the awk-statement to:

  awk 'BEGIN{FS=":|: "} /^mail:/ {print $2}'

.... just to be on the safe side.

Moreover I found out that the manpage recommends to add quotes and
braces for the search even if it's only one single attribute/value
pair. Thus, replace

  uid=strk

by

  "(uid=strk)"

If you expect non-ASCII characters in EMail adresses, things might get
a little more complicated :wink:

  Martin.
--
Unix _IS_ user friendly - it's just selective about who its friends are !
--------------------------------------------------------------------------

On Mon, Oct 19, 2015 at 12:02:06PM +0200, Martin Spott wrote:

On Mon, Oct 19, 2015 at 11:17:45AM +0200, Martin Spott wrote:

> tracsvn: 2:17:01 ~> [...]

Maybe refine the awk-statement to:

  awk 'BEGIN{FS=":|: "} /^mail:/ {print $2}'

.... just to be on the safe side.

Moreover I found out that the manpage recommends to add quotes and
braces for the search even if it's only one single attribute/value
pair. Thus, replace

  uid=strk

by

  "(uid=strk)"

Thanks, updated with:

/usr/bin/ldapsearch -H ldaps://ldap.osgeo.org/ \
  -b dc=osgeo,dc=org -x \
  "(uid=${author})" mail \
  | grep '^mail:' | cut -d: -f2

If you expect non-ASCII characters in EMail adresses, things might get
a little more complicated :wink:

Not in the email part. I actually expect them in the "cn" field
which seem to be the real name (Common Name?) but for now that
field is not used by the script

--strk;

On Mon, Oct 19, 2015 at 12:13:57PM +0200, Sandro Santilli wrote:

Thanks, updated with:

/usr/bin/ldapsearch -H ldaps://ldap.osgeo.org/ \
  -b dc=osgeo,dc=org -x \
  "(uid=${author})" mail \
  | grep '^mail:' | cut -d: -f2

> If you expect non-ASCII characters in EMail adresses, things might get
> a little more complicated :wink:

Not in the email part. I actually expect them in the "cn" field
which seem to be the real name (Common Name?) but for now that
field is not used by the script

Actually I've now further updated it to use your awk command
(to properly strip spaces) and also added Real Name, which is
known to contain UTF8 characters. Is that a problem ?

--strk;