/[ldap.old]/pg2ldap.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /pg2ldap.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Wed May 3 08:26:04 2000 UTC (19 years, 2 months ago) by dpavlin
Branch: DbP, MAIN
CVS Tags: r0, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: text/plain
početni import

1 dpavlin 1.1 #!/usr/local/bin/perl -w
2    
3     use strict;
4     use Net::LDAP;
5     use DBI;
6    
7     my $ldap = Net::LDAP->new('ldap.pliva.hr',port=>389) || die "$@";
8    
9     $ldap->bind ( # bind to a directory with dn and password
10     dn => 'cn=Directory Manager',
11     password => 'ribirep0');
12     # dn => 'cn=admin',
13     # password => 'ribirep');
14    
15     my $dbh = DBI->connect("DBI:Pg:dbname=informatika","","") || die $DBI::errstr;
16    
17     my $sth = $dbh->prepare("
18     select ime,prezime,alias
19     from osobe,e_mail
20     where osobe.id=e_mail.osoba_id
21     ") || die $dbh->errstr();
22     $sth->execute() || die $sth->errstr();
23    
24     while (my ($ime,$prezime,$alias) = $sth->fetchrow_array() ) {
25    
26     my $result = $ldap->add (
27     dn => "cn=$ime $prezime,o=pliva.hr",
28     attr => [
29     'givenname' => "$ime",
30     'sn' => "$prezime",
31     'cn' => "$ime $prezime",
32     'mail' => $alias.'@pliva.hr',
33     'objectclass' => ['top', 'person',
34     'organizationalPerson', 'inetOrgPerson' ]
35     ] );
36     $result->code && warn "failed to add entry: ", $result->error ;
37     print "$alias\n";
38    
39     }

  ViewVC Help
Powered by ViewVC 1.1.26