Hi, On Thursday 07 July 2005 17:50, Brian Gaber wrote: > Sorry, I should have provided more detail for my original post. > The code below is a snippet from a cgi-bin script that allows an LDAP > administrator to add a new ou via a webpage. The webpage just allows the > admin to specify the new fully qualified ou, e.g. ou=test,ou=ncr,o=pwgsc. > From that data that comes as a HTTP POST I want to create the new ou, e.g. > test. Hence I have no LDIF to parse. > > My preference is to use either $ldap->modify or $ldap->add in the converted > code > > How would the following code be coverted to use Perl-LDAP?
Please don't expect me to do the coding for you, but here's a sketch what you can do: If you have the object's DN you can create a Net::LDAP::Entry object, use it's methods to add, change or delete attributes in the object as you need them and finally use Net::LDAP's $ldap->update() method to write the file to the directory server. The man pages for Net::LDAP::Entry and Net::LDAP are quite detailed. > my $ldapmodify = "ldapmodify -h $ldap_master -x -c"; > my $context = "ou=test,ou=ncr,o=pwgsc"; > my $new_ou = "test"; > > open (LDAP, "|".$ldapmodify); > print LDAP "dn: $context\n"; > print LDAP "changetype: add\n"; > print LDAP "objectclass: organizationalunit\n"; > print LDAP "ou: $new_ou\n"; > close (LDAP); You have an LDIF: if you write this to a file instead of piping it to ldapmodify, you have an LDIF file. Peter -- Peter Marschall eMail: [EMAIL PROTECTED]
