summaryrefslogtreecommitdiffstats
path: root/debian/tests/create_account
blob: a5051af49bd2bf0bf7f4393eb64dd935dc94cc04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /usr/bin/perl -w

# Shows how to create an entry on the LDAP server

$host = "localhost";			# LDAP server
$basedn = "dc=galaxy";			# Base DN
$admindn = "cn=admin, $basedn";		# Admin entry
$adminpass = "foo";			# Password

use Net::LDAP;

$ldap = Net::LDAP->new("$host", onerror => "die");
$ldap->bind($admindn, password => $adminpass);

# Create "ou=People" entry if not there

$results = $ldap->search(base => "$basedn", 
	filter => "ou=People", scope => "one");
unless ($results->count > 0) {
	$ldap->add("ou=People, $basedn", attr => [
		  ou => "People", 
		  objectClass => [ "top", "organizationalUnit" ]
		]);
}