From: eric G. <eri...@wa...> - 2002-04-09 19:41:41
|
----- Original Message ----- From: karl rossing <un...@ya...> To: <per...@li...> Sent: Monday, April 08, 2002 8:12 PM Subject: Using Net::LDAP::Entry > Hi, > > I'm trying to use Net::LDAP::Entry to add a value to > an attribute on my LDAP server. > > Sepecificly i'm trying to get a script working that > will add and remove users from a particular netgroup > from my native solaris netgroup. > > > I'm probaly missing something from the script, but i > can't see it. > > Thanks > > Karl > > > __________________________________________________ > Do You Yahoo!? > Yahoo! Tax Center - online filing with TurboTax > http://taxes.yahoo.com/ ---------------------------------------------------------------------------- ---- > #!/usr/bin/perl > > use Net::LDAP; > use Net::LDAP::Entry; > > $DEBUG = 0; > > $base_dn = "o=domain.com"; > $ldap_host = "ldap.server.com"; > $dirmgr_passwd = "123456"; > > sub usage () { > print "Usage:\n"; > print "$PROGRAM_NAME {Add/Remove} Netgroup Userid \n"; > print "Example: $PROGRAM_NAME add winnipeg-users Userid\n"; > print "Example: $PROGRAM_NAME del goldeye-users Userid\n\n"; > } > > if ( @ARGV != 3 ) { > usage (); > exit (1); > } > > > ############################################################################ # > # Open the LDAP connection > # > sub openldap { > my $ldap; > $ldap = Net::LDAP->new($ldap_host) or die "$@"; > $ldap -> bind ("cn=directory manager", password => $dirmgr_passwd); > return ($ldap); > > } > > sub addtonisnetgroup { > my $ldap = shift; > my $nisnetgroup = shift;# > $entry = Net::LDAP::Entry->new; > > $result =$entry->add( 'nisnetgrouptriple' => '$userid' , dn => "cn=$nsnetgroup, ou=netgroup, $base_dn",); IMHO you may try "$userid" instead '$userid' , in perl a variable between \' is not expansed . $a+ eric german > # $result->code && warn "failed to add entry: ", $result->error ; > } > > $ldap = openldap (); > > # Parse out the args --> firstname lastname userid password"; > ($task, $netgroup, $userid) = @ARGV; > > addtonisnetgroup($task, $nsnetgroup, $userid); > |