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

Mailing list query

Hello all,

My user.ldif is like:

dn: cn=Somename Somelastname, ou=Users,dc=mydomain,dc=edu,dc=com
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: person
objectClass: organizationalPerson
objectClass: top
givenName: Somename
sn: Somelastname
cn: Somename Somelastname
uid: ssomelastname
uidNumber: 1002
gidNumber: 100
homeDirectory: /home/ssomelastname
loginShell: /bin/bash
mail: ssomelastname@mydomain.edu.com
userPassword: some password encrypted

Same user for example is under cn=IT,ou=Groups,dc=mydomain,dc=edu,dc=com
Example ldif:

dn: cn=IT,ou=Groups,dc=bca,dc=edu,dc=gr
cn: IT
objectClass: groupOfUniqueNames
uniqueMember: cn=Somename Somelastname,ou=Users,dc=mydomain,dc=edu,dc=com

What I want is somehow to get all uid of the users belonging to each
of my groups in order to build a mailing list with postfix.

I've created a file called ldap-aliases.cf with the following inside:

server_host = ldaps://myhostname
search_base = dc=mydomain,dc=edu,dc=com
scope = sub
version = 3
query_filter = (&(|(objectclass=person)(objectclass=groupofuniquenames)(mail=%s)(ou=Groups)))
result_attribute = uid
bind = yes
bind_dn = cn=admin,dc=mydomain,dc=edu,dc=com
bind_pw = mypasswordwithoutencryption

The above works ok without errors but it just displays all users in my ldap.
I tried several different ways but can't find out how to add to the
query to show me only the cn=IT,ou=Groups,dc=mydomain,dc=edu,dc=com

and also a second more complicated query, that is to show me all users
uid where not belonging to any Group

Any help is much appreciated.