#!/usr/bin/perl use CGI; use Net::LDAP; use Net::LDAP::Entry; use Net::LDAP::Util qw( ldap_error_name ldap_error_text); #prepare entry $entry = Net::LDAP::Entry->new(); $addinfo = CGI->new(); my $index = 5000; my($sec, $min, $hour, $day, $mon, $year, $wday, %yday, $isdst) = local +time; $mon += 1; $year += 1900; $dn = "index=" . $index . ", o=cert"; $entry->dn($dn); $entry->add('objectclass' => 'certentry', 'index' => $index, 'openedOn' => $year . $mon . $day . '000000', ); #bind to server $ldap = Net::LDAP->new("shiva.mydomain.com", port => 389) || die("Failed to connect to LDAP host.\n"); $mesg = $ldap->bind("cn=root", password => "root", version => 3); LDAPerror("Bind", $mesg); #add entry to server $mesg = $ldap->add($entry); LDAPerror("Adding", $mesg); #unbind $ldap->unbind; sub LDAPerror { my ($from,$mesg) = @_; print "\n$from\nReturn code: ",$mesg->code ; print "\tMessage: ", ldap_error_name($mesg->code); print " :", ldap_error_text($mesg->code); print "MessageID: ",$mesg->mesg_id; print "\tDN: ",$mesg->dn; print "\n"; #--- # Programmer note: # # "$mesg->error" DOESN'T work!!! # #print "\tMessage: ", $mesg->error; #----- }
In reply to Re: Re: "print" in a CGI script.
by shivapd
in thread "print" in a CGI script.
by shivapd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |