#! /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" ] ]); }