mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
API.xs - Added missing functions (bind/bind_s)
api.pl - Made a few misc changes...minor... (removed system calls/fixed rebind) constant.h - Completely changed this file to streamline response. Might still want to move SUCCESS, SCOPE, and a few others out of the new switch/case thing.
This commit is contained in:
parent
72ec0a7a16
commit
8ca115e86b
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* $Id: constant.h,v 1.5 1998/07/29 02:58:54 leif Exp $
|
||||
* $Id: constant.h,v 1.6 1998/08/03 00:26:37 clayton Exp $
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
@ -51,14 +51,11 @@ char *name;
|
||||
int arg;
|
||||
{
|
||||
errno = 0;
|
||||
switch (*name) {
|
||||
case 'L':
|
||||
if (strEQ(name, "LDAPS_PORT"))
|
||||
#ifdef LDAPS_PORT
|
||||
return LDAPS_PORT;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
if (name[0] == 'L' && name[1] == 'D' && name[2] == 'A' && name[3] == 'P'
|
||||
&& name[4] == '_')
|
||||
{
|
||||
switch (name[5]) {
|
||||
case 'A':
|
||||
if (strEQ(name, "LDAP_ADMINLIMIT_EXCEEDED"))
|
||||
#ifdef LDAP_ADMINLIMIT_EXCEEDED
|
||||
return LDAP_ADMINLIMIT_EXCEEDED;
|
||||
@ -119,12 +116,16 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'B':
|
||||
if (strEQ(name, "LDAP_BUSY"))
|
||||
#ifdef LDAP_BUSY
|
||||
return LDAP_BUSY;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'C':
|
||||
if (strEQ(name, "LDAP_CACHE_CHECK"))
|
||||
#ifdef LDAP_CACHE_CHECK
|
||||
return LDAP_CACHE_CHECK;
|
||||
@ -215,6 +216,8 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'D':
|
||||
if (strEQ(name, "LDAP_DEREF_ALWAYS"))
|
||||
#ifdef LDAP_DEREF_ALWAYS
|
||||
return LDAP_DEREF_ALWAYS;
|
||||
@ -239,12 +242,16 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'E':
|
||||
if (strEQ(name, "LDAP_ENCODING_ERROR"))
|
||||
#ifdef LDAP_ENCODING_ERROR
|
||||
return LDAP_ENCODING_ERROR;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'F':
|
||||
if (strEQ(name, "LDAP_FILTER_ERROR"))
|
||||
#ifdef LDAP_FILTER_ERROR
|
||||
return LDAP_FILTER_ERROR;
|
||||
@ -257,6 +264,8 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'I':
|
||||
if (strEQ(name, "LDAP_INAPPROPRIATE_AUTH"))
|
||||
#ifdef LDAP_INAPPROPRIATE_AUTH
|
||||
return LDAP_INAPPROPRIATE_AUTH;
|
||||
@ -299,6 +308,8 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'L':
|
||||
if (strEQ(name, "LDAP_LOCAL_ERROR"))
|
||||
#ifdef LDAP_LOCAL_ERROR
|
||||
return LDAP_LOCAL_ERROR;
|
||||
@ -311,6 +322,8 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'M':
|
||||
if (strEQ(name, "LDAP_MOD_ADD"))
|
||||
#ifdef LDAP_MOD_ADD
|
||||
return LDAP_MOD_ADD;
|
||||
@ -359,6 +372,8 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'N':
|
||||
if (strEQ(name, "LDAP_NAMING_VIOLATION"))
|
||||
#ifdef LDAP_NAMING_VIOLATION
|
||||
return LDAP_NAMING_VIOLATION;
|
||||
@ -419,6 +434,8 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'O':
|
||||
if (strEQ(name, "LDAP_OBJECT_CLASS_VIOLATION"))
|
||||
#ifdef LDAP_OBJECT_CLASS_VIOLATION
|
||||
return LDAP_OBJECT_CLASS_VIOLATION;
|
||||
@ -599,6 +616,8 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'P':
|
||||
if (strEQ(name, "LDAP_PARAM_ERROR"))
|
||||
#ifdef LDAP_PARAM_ERROR
|
||||
return LDAP_PARAM_ERROR;
|
||||
@ -629,6 +648,8 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'R':
|
||||
if (strEQ(name, "LDAP_REFERRAL"))
|
||||
#ifdef LDAP_REFERRAL
|
||||
return LDAP_REFERRAL;
|
||||
@ -719,6 +740,8 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'S':
|
||||
if (strEQ(name, "LDAP_SASL_BIND_IN_PROGRESS"))
|
||||
#ifdef LDAP_SASL_BIND_IN_PROGRESS
|
||||
return LDAP_SASL_BIND_IN_PROGRESS;
|
||||
@ -791,6 +814,8 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'T':
|
||||
if (strEQ(name, "LDAP_TIMELIMIT_EXCEEDED"))
|
||||
#ifdef LDAP_TIMELIMIT_EXCEEDED
|
||||
return LDAP_TIMELIMIT_EXCEEDED;
|
||||
@ -809,6 +834,8 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'U':
|
||||
if (strEQ(name, "LDAP_UNAVAILABLE"))
|
||||
#ifdef LDAP_UNAVAILABLE
|
||||
return LDAP_UNAVAILABLE;
|
||||
@ -875,6 +902,8 @@ int arg;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
case 'V':
|
||||
if (strEQ(name, "LDAP_VERSION"))
|
||||
#ifdef LDAP_VERSION
|
||||
return LDAP_VERSION;
|
||||
@ -906,7 +935,16 @@ int arg;
|
||||
goto not_there;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (strEQ(name, "LDAPS_PORT"))
|
||||
#ifdef LDAPS_PORT
|
||||
return LDAPS_PORT;
|
||||
#else
|
||||
goto not_there;
|
||||
#endif
|
||||
}
|
||||
|
||||
errno = EINVAL;
|
||||
return 0;
|
||||
|
||||
|
@ -1,273 +1,269 @@
|
||||
#!/usr/bin/perl -w
|
||||
#############################################################################
|
||||
# $Id: api.pl,v 1.3 1998/07/31 21:16:30 clayton Exp $
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License
|
||||
# Version 1.0 (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS"
|
||||
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing rights and limitations
|
||||
# under the License.
|
||||
#
|
||||
# The Original Code is PerlDAP. The Initial Developer of the Original
|
||||
# Code is Netscape Communications Corp. and Clayton Donley. Portions
|
||||
# created by Netscape are Copyright (C) Netscape Communications
|
||||
# Corp., portions created by Clayton Donley are Copyright (C) Clayton
|
||||
# Donley. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# DESCRIPTION
|
||||
# api.pl - Test all LDAPv2 API function
|
||||
# Author: Clayton Donley <donley@wwa.com>
|
||||
#
|
||||
# Performs all API calls directly in order to test for possible issues
|
||||
# on a particular platform.
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
use Mozilla::LDAP::API qw(:api :constant);
|
||||
use strict;
|
||||
|
||||
my $BASE = "ou=Test,o=Motorola,c=US";
|
||||
my $DN = "cn=DSManager,o=Motorola,c=US";
|
||||
my $PASS = "abcd1234";
|
||||
my $HOST = "localhost";
|
||||
my $PORT = 389;
|
||||
|
||||
$howmany = 50;
|
||||
|
||||
# Initialize the Connection
|
||||
{
|
||||
my $ld = ldap_init($HOST,$PORT);
|
||||
if ($ld <0)
|
||||
{
|
||||
print "init - Failed!\n";
|
||||
die;
|
||||
}
|
||||
print "init - OK\n";
|
||||
|
||||
# Set an LDAP Session Option
|
||||
if (ldap_set_option($ld,LDAP_OPT_PROTOCOL_VERSION,LDAP_VERSION3)
|
||||
!= LDAP_SUCCESS)
|
||||
{
|
||||
print "set_option - Failed!\n";
|
||||
} else {
|
||||
print "set_option - OK\n";
|
||||
}
|
||||
|
||||
# Get an LDAP Session Option
|
||||
my $option;
|
||||
ldap_get_option($ld,LDAP_OPT_REFERRALS,$option);
|
||||
|
||||
if ($option != 1)
|
||||
{
|
||||
print "get_option - Failed!\n";
|
||||
} else {
|
||||
print "get_option - OK\n";
|
||||
}
|
||||
|
||||
# Anonymous Bind
|
||||
if (ldap_simple_bind_s($ld,"","") != LDAP_SUCCESS)
|
||||
{
|
||||
print "anon_bind - Failed!\n";
|
||||
} else {
|
||||
print "anon_bind - OK\n";
|
||||
}
|
||||
|
||||
# Authenticated Simple Bind
|
||||
if (ldap_simple_bind_s($ld,$DN,$PASS) != LDAP_SUCCESS)
|
||||
{
|
||||
print "simple_bind - Failed!\n";
|
||||
} else {
|
||||
print "simple_bind - OK\n";
|
||||
}
|
||||
|
||||
# Set Rebind Process
|
||||
my $rebindproc = sub { return($DN,$PASS,LDAP_AUTH_SIMPLE); };
|
||||
if (ldap_set_rebind_proc($ld,$rebindproc) != LDAP_SUCCESS)
|
||||
{
|
||||
print "set_rebind - Failed!\n";
|
||||
} else {
|
||||
print "set_rebind - OK\n";
|
||||
}
|
||||
|
||||
# Add an OrgUnit Entry
|
||||
my $entry = {
|
||||
"objectclass" => ["top","organizationalUnit"],
|
||||
"ou" => "Test",
|
||||
};
|
||||
|
||||
if (ldap_add_s($ld,$BASE,$entry) != LDAP_SUCCESS)
|
||||
{
|
||||
print "add_org - Failed!\n";
|
||||
} else {
|
||||
print "add_org - OK\n";
|
||||
}
|
||||
|
||||
|
||||
# Add People
|
||||
foreach my $number (1..$howmany)
|
||||
{
|
||||
$entry = {
|
||||
"objectclass" => ["top","person"],
|
||||
"cn" => "Mozilla $number",
|
||||
"sn" => ["$number"],
|
||||
};
|
||||
if (ldap_add_s($ld,"cn=Mozilla $number,$BASE",$entry)
|
||||
!= LDAP_SUCCESS)
|
||||
{
|
||||
print "add_user_$number - Failed!\n";
|
||||
} else {
|
||||
print "add_user_$number - OK\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Modify People
|
||||
foreach my $number (1..$howmany)
|
||||
{
|
||||
$entry = {
|
||||
"sn" => {"a",["Test"]},
|
||||
"telephoneNumber" => "800-555-111$number",
|
||||
};
|
||||
if (ldap_modify_s($ld,"cn=Mozilla $number,$BASE",$entry)
|
||||
!= LDAP_SUCCESS)
|
||||
{
|
||||
print "mod_user_$number - Failed!\n";
|
||||
} else {
|
||||
print "mod_user_$number - OK\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Search People
|
||||
my $filter = "(sn=Test)";
|
||||
my $attrs = ["cn","sn"];
|
||||
my $res;
|
||||
if (ldap_search_s($ld,$BASE,LDAP_SCOPE_SUBTREE,$filter,$attrs,0,$res)
|
||||
!= LDAP_SUCCESS)
|
||||
{
|
||||
print "search_user - Failed!\n";
|
||||
} else {
|
||||
print "search_user - OK\n";
|
||||
}
|
||||
|
||||
# Count Results
|
||||
if (ldap_count_entries($ld,$res) != $howmany)
|
||||
{
|
||||
print "count_res - Failed!\n";
|
||||
} else {
|
||||
print "count_res - OK\n";
|
||||
}
|
||||
|
||||
# Sort Results
|
||||
if (ldap_sort_entries($ld,$res,"sn") != LDAP_SUCCESS)
|
||||
{
|
||||
print "sort_ent - Failed!\n";
|
||||
} else {
|
||||
print "sort_ent - OK\n";
|
||||
}
|
||||
|
||||
# Multisort Results
|
||||
if (ldap_multisort_entries($ld,$res,["sn","telephoneNumber"]) != LDAP_SUCCESS)
|
||||
{
|
||||
print "multisort - Failed!\n";
|
||||
} else {
|
||||
print "multisort - OK\n";
|
||||
}
|
||||
|
||||
# Get First Entry
|
||||
my $ent = ldap_first_entry($ld,$res);
|
||||
if (!$ent)
|
||||
{
|
||||
print "first_entry - Failed!\n";
|
||||
} else {
|
||||
print "first_entry - OK\n";
|
||||
}
|
||||
|
||||
# Get Next Entry
|
||||
$ent = ldap_next_entry($ld,$ent);
|
||||
if (!$ent)
|
||||
{
|
||||
print "next_entry - Failed!\n";
|
||||
} else {
|
||||
print "next_entry - OK\n";
|
||||
}
|
||||
|
||||
# Get DN
|
||||
my $dn = ldap_get_dn($ld,$ent);
|
||||
if (!$dn)
|
||||
{
|
||||
print "get_dn - Failed!\n";
|
||||
} else {
|
||||
print "get_dn - OK\n";
|
||||
}
|
||||
|
||||
# Get First Attribute
|
||||
my $ber;
|
||||
my $attr = ldap_first_attribute($ld,$ent,$ber);
|
||||
if (!$attr)
|
||||
{
|
||||
print "first_attr - Failed!\n";
|
||||
} else {
|
||||
print "first_attr - OK\n";
|
||||
}
|
||||
|
||||
# Get Next Attribute
|
||||
$attr = ldap_next_attribute($ld,$ent,$ber);
|
||||
if (!$attr)
|
||||
{
|
||||
print "next_attr - Failed!\n";
|
||||
} else {
|
||||
print "next_attr - OK\n";
|
||||
}
|
||||
|
||||
# Get Attribute Values
|
||||
my @vals = ldap_get_values($ld,$ent,$attr);
|
||||
if ($#vals < 0)
|
||||
{
|
||||
print "get_values - Failed!\n";
|
||||
} else {
|
||||
print "get_values - OK\n";
|
||||
}
|
||||
|
||||
# Free structures pointed to by $ber and $res to prevent memory leak
|
||||
ldap_ber_free($ber,0);
|
||||
ldap_msgfree($res);
|
||||
|
||||
# Compare Attribute Values
|
||||
foreach my $number (1..$howmany)
|
||||
{
|
||||
if(ldap_compare_s($ld,"cn=Mozilla $number,$BASE","sn",$number)
|
||||
!= LDAP_COMPARE_TRUE)
|
||||
{
|
||||
print "comp_user_$number - Failed!\n";
|
||||
} else {
|
||||
print "comp_user_$number - OK\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Delete Users
|
||||
foreach my $number (1..$howmany)
|
||||
{
|
||||
if (ldap_delete_s($ld,"cn=Mozilla $number,$BASE") != LDAP_SUCCESS)
|
||||
{
|
||||
print "del_user_$number - Failed!\n";
|
||||
} else {
|
||||
print "del_user_$number - OK\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (ldap_delete_s($ld,"$BASE") != LDAP_SUCCESS)
|
||||
{
|
||||
print "del_org - Failed!\n";
|
||||
} else {
|
||||
print "del_org - OK\n";
|
||||
}
|
||||
|
||||
# Unbind
|
||||
ldap_unbind($ld);
|
||||
}
|
||||
#!/usr/bin/perl -w
|
||||
#############################################################################
|
||||
# $Id: api.pl,v 1.4 1998/08/03 00:26:38 clayton Exp $
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License
|
||||
# Version 1.0 (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS"
|
||||
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing rights and limitations
|
||||
# under the License.
|
||||
#
|
||||
# The Original Code is PerlDAP. The Initial Developer of the Original
|
||||
# Code is Netscape Communications Corp. and Clayton Donley. Portions
|
||||
# created by Netscape are Copyright (C) Netscape Communications
|
||||
# Corp., portions created by Clayton Donley are Copyright (C) Clayton
|
||||
# Donley. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# DESCRIPTION
|
||||
# api.pl - Test all LDAPv2 API function
|
||||
# Author: Clayton Donley <donley@wwa.com>
|
||||
#
|
||||
# Performs all API calls directly in order to test for possible issues
|
||||
# on a particular platform.
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
use Mozilla::LDAP::API qw(:api :constant);
|
||||
use strict;
|
||||
|
||||
my $BASE = "ou=Test,o=Test,c=US";
|
||||
my $DN = "cn=Directory Manager";
|
||||
my $PASS = "abcd1234";
|
||||
my $HOST = "localhost";
|
||||
my $PORT = 389;
|
||||
|
||||
my $howmany = 10;
|
||||
|
||||
# Initialize the Connection
|
||||
{
|
||||
my $ld = ldap_init($HOST,$PORT);
|
||||
if ($ld <0)
|
||||
{
|
||||
print "init - Failed!\n";
|
||||
die;
|
||||
}
|
||||
print "init - OK\n";
|
||||
|
||||
# Set an LDAP Session Option
|
||||
if (ldap_set_option($ld,LDAP_OPT_PROTOCOL_VERSION,LDAP_VERSION3)
|
||||
!= LDAP_SUCCESS)
|
||||
{
|
||||
print "set_option - Failed!\n";
|
||||
} else {
|
||||
print "set_option - OK\n";
|
||||
}
|
||||
|
||||
# Get an LDAP Session Option
|
||||
my $option;
|
||||
ldap_get_option($ld,LDAP_OPT_REFERRALS,$option);
|
||||
|
||||
if ($option != 1)
|
||||
{
|
||||
print "get_option - Failed!\n";
|
||||
} else {
|
||||
print "get_option - OK\n";
|
||||
}
|
||||
|
||||
# Anonymous Bind
|
||||
if (ldap_simple_bind_s($ld,"","") != LDAP_SUCCESS)
|
||||
{
|
||||
print "anon_bind - Failed!\n";
|
||||
} else {
|
||||
print "anon_bind - OK\n";
|
||||
}
|
||||
|
||||
# Authenticated Simple Bind
|
||||
if (ldap_simple_bind_s($ld,$DN,$PASS) != LDAP_SUCCESS)
|
||||
{
|
||||
print "simple_bind - Failed!\n";
|
||||
} else {
|
||||
print "simple_bind - OK\n";
|
||||
}
|
||||
|
||||
# Set Rebind Process
|
||||
my $rebindproc = sub { return($DN,$PASS,LDAP_AUTH_SIMPLE); };
|
||||
ldap_set_rebind_proc($ld,$rebindproc);
|
||||
print "set_rebind - OK\n";
|
||||
|
||||
# Add an OrgUnit Entry
|
||||
my $entry = {
|
||||
"objectclass" => ["top","organizationalUnit"],
|
||||
"ou" => "Test",
|
||||
};
|
||||
|
||||
if (ldap_add_s($ld,$BASE,$entry) != LDAP_SUCCESS)
|
||||
{
|
||||
print "add_org - Failed!\n";
|
||||
} else {
|
||||
print "add_org - OK\n";
|
||||
}
|
||||
|
||||
|
||||
# Add People
|
||||
foreach my $number (1..$howmany)
|
||||
{
|
||||
$entry = {
|
||||
"objectclass" => ["top","person"],
|
||||
"cn" => "Mozilla $number",
|
||||
"sn" => ["$number"],
|
||||
};
|
||||
if (ldap_add_s($ld,"cn=Mozilla $number,$BASE",$entry)
|
||||
!= LDAP_SUCCESS)
|
||||
{
|
||||
print "add_user_$number - Failed!\n";
|
||||
} else {
|
||||
print "add_user_$number - OK\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Modify People
|
||||
foreach my $number (1..$howmany)
|
||||
{
|
||||
$entry = {
|
||||
"sn" => {"a",["Test"]},
|
||||
"telephoneNumber" => "800-555-111$number",
|
||||
};
|
||||
if (ldap_modify_s($ld,"cn=Mozilla $number,$BASE",$entry)
|
||||
!= LDAP_SUCCESS)
|
||||
{
|
||||
print "mod_user_$number - Failed!\n";
|
||||
} else {
|
||||
print "mod_user_$number - OK\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Search People
|
||||
my $filter = "(sn=Test)";
|
||||
my $attrs = ["cn","sn"];
|
||||
my $res;
|
||||
if (ldap_search_s($ld,$BASE,LDAP_SCOPE_SUBTREE,$filter,$attrs,0,$res)
|
||||
!= LDAP_SUCCESS)
|
||||
{
|
||||
print "search_user - Failed!\n";
|
||||
} else {
|
||||
print "search_user - OK\n";
|
||||
}
|
||||
|
||||
# Count Results
|
||||
if (ldap_count_entries($ld,$res) != $howmany)
|
||||
{
|
||||
print "count_res - Failed!\n";
|
||||
} else {
|
||||
print "count_res - OK\n";
|
||||
}
|
||||
|
||||
# Sort Results
|
||||
if (ldap_sort_entries($ld,$res,"sn") != LDAP_SUCCESS)
|
||||
{
|
||||
print "sort_ent - Failed!\n";
|
||||
} else {
|
||||
print "sort_ent - OK\n";
|
||||
}
|
||||
|
||||
# Multisort Results
|
||||
if (ldap_multisort_entries($ld,$res,["sn","telephoneNumber"]) != LDAP_SUCCESS)
|
||||
{
|
||||
print "multisort - Failed!\n";
|
||||
} else {
|
||||
print "multisort - OK\n";
|
||||
}
|
||||
|
||||
# Get First Entry
|
||||
my $ent = ldap_first_entry($ld,$res);
|
||||
if (!$ent)
|
||||
{
|
||||
print "first_entry - Failed!\n";
|
||||
} else {
|
||||
print "first_entry - OK\n";
|
||||
}
|
||||
|
||||
# Get Next Entry
|
||||
$ent = ldap_next_entry($ld,$ent);
|
||||
if (!$ent)
|
||||
{
|
||||
print "next_entry - Failed!\n";
|
||||
} else {
|
||||
print "next_entry - OK\n";
|
||||
}
|
||||
|
||||
# Get DN
|
||||
my $dn = ldap_get_dn($ld,$ent);
|
||||
if (!$dn)
|
||||
{
|
||||
print "get_dn - Failed!\n";
|
||||
} else {
|
||||
print "get_dn - OK\n";
|
||||
}
|
||||
|
||||
# Get First Attribute
|
||||
my $ber;
|
||||
my $attr = ldap_first_attribute($ld,$ent,$ber);
|
||||
if (!$attr)
|
||||
{
|
||||
print "first_attr - Failed!\n";
|
||||
} else {
|
||||
print "first_attr - OK\n";
|
||||
}
|
||||
|
||||
# Get Next Attribute
|
||||
$attr = ldap_next_attribute($ld,$ent,$ber);
|
||||
if (!$attr)
|
||||
{
|
||||
print "next_attr - Failed!\n";
|
||||
} else {
|
||||
print "next_attr - OK\n";
|
||||
}
|
||||
|
||||
# Get Attribute Values
|
||||
my @vals = ldap_get_values($ld,$ent,$attr);
|
||||
if ($#vals < 0)
|
||||
{
|
||||
print "get_values - Failed!\n";
|
||||
} else {
|
||||
print "get_values - OK\n";
|
||||
}
|
||||
|
||||
# Free structures pointed to by $ber and $res to prevent memory leak
|
||||
ldap_ber_free($ber,1);
|
||||
ldap_msgfree($res);
|
||||
|
||||
# Compare Attribute Values
|
||||
foreach my $number (1..$howmany)
|
||||
{
|
||||
if(ldap_compare_s($ld,"cn=Mozilla $number,$BASE","sn",$number)
|
||||
!= LDAP_COMPARE_TRUE)
|
||||
{
|
||||
print "comp_user_$number - Failed!\n";
|
||||
} else {
|
||||
print "comp_user_$number - OK\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Delete Users
|
||||
foreach my $number (1..$howmany)
|
||||
{
|
||||
if (ldap_delete_s($ld,"cn=Mozilla $number,$BASE") != LDAP_SUCCESS)
|
||||
{
|
||||
print "del_user_$number - Failed!\n";
|
||||
} else {
|
||||
print "del_user_$number - OK\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (ldap_delete_s($ld,"$BASE") != LDAP_SUCCESS)
|
||||
{
|
||||
print "del_org - Failed!\n";
|
||||
} else {
|
||||
print "del_org - OK\n";
|
||||
}
|
||||
|
||||
# Unbind
|
||||
ldap_unbind($ld);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user