[squid-users] Perl Group Ldap Auth

From: Riccardo Baldanzi <[email protected]>
Date: Wed, 20 Feb 2002 15:54:01 +0100

Hi all,

me and a colleague have written a perl script for group ldap auth (we use
with M$ Active Directory).

Hope this helps.

King Regdards,

Riccardo Baldanzi
Efrem Locarno

P.S. i'm going to integrate LDAP query directly with perl functions (i.e.
with Net::LDAP)

That's the code:

#!/usr/bin/perl
#Authors:
#Riccardo Baldanzi riccardo.baldanzi@tin.it
#Locarno Efrem locarno@imunant.com
#20-02-2002
#group ldap authentication

while (<STDIN>)
{
chomp;

#flush STDOUT
$|=1;

#STDIN input
@params = split / /;
$username = @params[0];
$password = @params[1];

if ($username eq "")
{
        print "ERR\n";
}
else
{
        @array=qx(ldapsearch -LLL -D CN=$username,CN=Users,DC=yourcompany,DC=com
-w $password -b CN=InternetGroup,CN=Builtin,DC=yourcompany,DC=com -x -v -s
sub -h 10.1.1.1 member=CN=$username,CN=Users,DC=yourcompany,DC=com
2>/dev/null);

        $isgood=0;

        foreach $linearr (@array)
        {if ($linearr=~m/distinguishedName/) {$isgood=1;}}

        if ($isgood==0) {print "ERR\n";} else {print "OK\n";}
}
}
Received on Wed Feb 20 2002 - 07:53:49 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 17:06:28 MST