How do I do that exactly ?
:)
--
Terry Davis
Systems Administrator
BirdDog Solutions, Inc.
(402) 829-6059
Quoting Jamie Cameron <jcameron@...>:
> That code looks pretty reasonable to me .. Have you tried redirecting
> the output to a file and printing some debug output to see what is going
> on?
>
> - Jamie
>
> Terry Davis <tdavis@...> wrote ..
> > Hello,
> > Sorry to be writing here but my command works fine outside of webmin, but
> > fails
> > altogether when I run it from webmin. I attached my program to this
> email.
> > If
> > anyone can give me any clues as to what I am doing wrong, I would really
> > appreciate it. I am a perl beginner so bear with me.
> >
> > Thank you!
> >
> >
> > ---START PROGRAM------
> > #!/usr/bin/perl
> > use Net::LDAP;
> > use Mail::Sendmail;
> >
> > $action = $ENV{ 'USERADMIN_ACTION' };
> > $username = "$ENV{ 'USERADMIN_USER' };
> > $uid = $ENV{ 'USERADMIN_UID' };
> > $gid = $ENV{ 'USERADMIN_GID' };
> > $real = $ENV{ 'USERADMIN_REAL' };
> > $home = $ENV{ 'USERADMIN_HOME' };
> > $shell = $ENV{ 'USERADMIN_SHELL' };
> > $pass = $ENV{ 'USERADMIN_PASS' };
> >
> > $ldaphost = "127.0.0.1";
> > $basedn = "dc=birddog,dc=com";
> > $rootdn = "cn=root";
> > $rootpw = "foobar";
> > $domain = "birddog.com";
> > $mailhost = "mail.birddog.com";
> > $givenName = "givenName";
> > $sn = "sn";
> > $rands = substr(time(),-4);
> > $salt = ('a'..'z')[int(($rands/100)%26)];
> > $salt .= ('a'..'z')[int(($rands%100)%26)];
> > $cryptdpass = crypt($newpass,$salt);
> >
> > if ( $action eq 'CREATE_USER' ){
> > create_user();
> > exit 0;
> > }
> > elsif ( $action eq 'MODIFY_USER' ){
> > modify_user();
> > exit 0;
> > }
> > elsif ( $action eq 'DELETE_USER' ){
> > delete_user();
> > exit 0;
> > }
> > else{
> > print "fuck, its broke";
> > exit 0;
> > }
> >
> > sub modify_user
> > {
> > $binddn = "uid=$username,ou=People,$basedn";
> > $ldap = Net::LDAP->new("$ldaphost") or die "$@";
> > $ldap->bind( dn => "$rootdn,$basedn", password => "$rootpw");
> > $message = $ldap->modify( $binddn,replace => { 'uid' =>
> "$username"
> > });
> > $message = $ldap->modify( $binddn,replace => { 'cn' => "$real"
> > });
> > $message = $ldap->modify( $binddn,replace => { 'sn' => "$sn" });
> > $message = $ldap->modify( $binddn,replace => { 'userPassword' =>
> > "{crypt}$cryptdpass" });
> > $message = $ldap->modify( $binddn,replace => { 'givenName' =>
> > "$givenName" });
> > $message = $ldap->modify( $binddn,replace => { 'mail' =>
> > "$username@..." });
> > $message = $ldap->modify( $binddn,replace => { 'uidNumber' =>
> "$uid"
> > });
> > $message = $ldap->modify( $binddn,replace => { 'gidNumber' =>
> "$gid"
> > });
> > $message = $ldap->modify( $binddn,replace => { 'homeDirectory'
> > =>
> > "$home" });
> > $message = $ldap->modify( $binddn,replace => { 'loginShell' =>
> > "$shell"
> > });
> > $message = $ldap->modify( $binddn,replace => { 'gecos' => "$real"
> > });
> > $message->code && warn "failed to add entry: ", $message->error
> > ;
> > }
> >
> > sub create_user
> > {
> > $ldap = Net::LDAP->new("$ldaphost") or die "$@";
> > $ldap->bind( dn => "$rootdn,$basedn", password => "$rootpw");
> > $result = $ldap->add(
> > dn => "uid=$username,ou=People,$basedn",
> > attr => [ 'cn' => "$real",
> > 'uid' => "$username",
> > 'sn' => "$sn",
> > 'userPassword' => "{crypt}$pass",
> > 'givenName' => "$givenName",
> > 'mail' => "$username@...",
> > 'uidNumber' => "$uid",
> > 'gidNumber' => "$gid",
> > 'homeDirectory' => "$home",
> > 'loginShell' => "$shell",
> > 'gecos' => "$real",
> > 'objectclass' =>
> >
>
['inetLocalMailRecipient','person','organizationalPerson','inetOrgPerson','accou
nt','posixAccount','top','shadowAccount']
> > ]
> > );
> > $result->code && warn "failed to add entry: ", $result->error ;
> > }
> >
> > sub delete_user
> > {
> > $binddn = "uid=$username,ou=People,$basedn";
> > $ldap = Net::LDAP->new("$ldaphost") or die "$@";
> > $ldap->bind( dn => "$rootdn,$basedn", password => "$rootpw");
> > $message = $ldap->delete( $binddn );
> > }
> > ------END PROGRAM-------
> >
> >
> > Thank you all once again!
-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
|