OpenVPN Access Server + OpenLDAP + memberOf
Posted: October 6th, 2009 | Author: jordan | Filed under: LDAP, VPN | 5 Comments » OpenVPN Access Server + OpenLDAP + memberOfI volunteer for an organization called Free Geek, it’s the local chapter here in vancouver and they are such an amazing group of people. Upon seeing the organization I felt compelled to get involved and offer my services as best I could for them. Since I’m a sysadmin by trade I figured that’s what I would do, although I what I did not know was the state of affairs in which their network lay. That is story onto itself however. For this post I’m going to be writing about the OpenVPN Access Server implementation I performed for them.
First, OpenVPN is a great product. Period. They make a secure, easy to configure and deploy, SSL based VPN solution. As long as you know how PKI works you can link multiple sites or users together in just a few minutes. For those of you though who do not want to bother all this command

OpenVPN AS User Portal

License Key

VPN Settings

LDAP Integration
In OpenLDAP it’s not common for a user entry to list what groups they are part of. In fact, it’s the other way around, you ask the group who its members are. Since OpenVPN want to use a filter on the user’s entry in OpenLDAP this setup was not going to work for me. Enter the memberOf overlay. For those of you who do not know what this does, let me explain. When you add a user to a group the user’s entry does not change, instead the group’s entry changes. So let’s say we add Sally to the group, lusers. If we queried the group lusers we would get an entry like:
memberUid: Sally
But if we queried Sally’s account it would appear the same as before we added her to this group. Therefore we need to modify our OpenLDAP install to allow for a reverse membership.
What I had to do was stop the ‘’slapd” service on my LDAP server and edit my slapd.conf file and add the following two lines.
moduleload memberof.la
overlay memberof
Then I had to create an ldif file with the following contents:
#contents of memberOf.ldif
dn: cn=vpn,ou=Groups,dc=shop,dc=lan
objectclass: groupofnames
cn: vpn
description: Users allowed to connect on VPN
member: uid=jordan,ou=People,dc=shop,dc=lan
And add this to my ldap database slapadd -f memberOf.ldif
After this I fired up the ldap server in debug to check for errors slapd -d 99 -f /etc/ldap/slapd.conf and check to make sure that my group membership of “vpn” was listed in my user entry. ldapsearch -h ldap -x -b "dc=shop,dc=lan" '(uid=jordan)' memberOf and bam! success!
# jordan, People, shop.lan
dn: uid=jordan,ou=People,dc=shop,dc=lan
memberOf: cn=vpn,ou=Groups,dc=shop,dc=lan
So I fired the init.d slapd service back up and went back to the OpenVPN admin interface. For the LDAP filter at the bottom of the window I entered memberof=cn=vpn,ou=Groups,dc=shop,dc=lan I saved and restarted the VPN service and poof. I now have authorization based on group membership!










Hi Jordan,
This is just what I’ve been looking for. Thanks for this great info.
Am having a few problems adding my ldif file.
I get “memberOf.ldif: line 2: unknown directive outside backend info and database definitions.
slapadd: bad configuration file!”
Any ideas why this should be? My LDAP skills are not all that brilliant…
Not sure if I should be using ldapadd instead?
Cheers,
c:)
Usually whenever I see a “bad configuration file” error it usually means that I’ve left some white space at the beginning of a line somewhere. Check your conf file for lines starting with whitespace. Let me know what you find.
Jordan
Hi Jordan,
Thanks for the response.
That was my original thought as well so I re-edited the ldif file by hand but I’m still getting the same error.
You mentioned that you already had a groupofnames called vpn set up. Maybe I’m missing that step.
Thanks,
Chris.
Hi Jordan,
Thought I’d give you an update.
Have managed to get the LDIF file loaded – my problem was that there was a group already loaded via smbldap-groupadd called “VPN” and this was causing a conflict. Once I removed this group the ldif loaded ok.
Unfortunately, my Cisco ASA5510 still doesn’t want to play ball. I’ve created an attribute map to the memberOf attribute but it doesn’t seem to read it.
Ho hum. more debugging ahead I think.
c:)
[...] Check it out. [...]