shekarkcb has asked for the wisdom of the Perl Monks concerning the following question:
I have a working script which is used to authenticate users for vpn using ldap for openvpn. The way script called is, in openvpn conf file ( /etc/openvpn/server.conf )
auth-user-pass-verify /etc/openvpn/ldap_authenticate.pl via-env
The script is as follows,
cat ldap_authenticate.pl
It works perfectly fine for users who are from#!/usr/bin/perl -w use Net::LDAP; use strict; my $ldap; my $result; my $opt_uri = "ldap://localhost"; my $opt_user = $ENV{'username'}; my $opt_passwd = $ENV{'password'}; my $opt_common = $ENV{'common_name'}; my $opt_group = "cn=vpnusers,ou=Groups,dc=mycompany,dc=com"; my $opt_binddn = "uid=".$opt_user.",ou=People,dc=mycompany,dc=com"; $ldap = Net::LDAP->new($opt_uri) or die("connect $opt_uri failed!"); $result = $ldap->bind($opt_binddn, password=>$opt_passwd); $result->code and $result = $ldap->bind("uid=".$opt_user.",ou=Interns, +dc=mycompany,dc=com", password=>$opt_passwd); $result->code and die($result->error); $result = $ldap->search(base=>$opt_group, filter=>"(&(memberUid=$opt_u +ser))"); $result->code(); if ($result->count == 1) { exit 0; } unless($result->count){ exit 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pointers required on understanding LDAP Authenticating script for openvpn
by Loops (Curate) on Apr 10, 2013 at 10:57 UTC | |
by shekarkcb (Beadle) on Apr 10, 2013 at 12:01 UTC | |
by influx (Beadle) on Apr 10, 2013 at 15:26 UTC | |
|
Re: Pointers required on understanding LDAP Authenticating script for openvpn
by Anonymous Monk on Apr 10, 2013 at 12:08 UTC | |
by shekarkcb (Beadle) on Apr 12, 2013 at 05:56 UTC |