For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2007 > perl script to modify LDAP.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author perl script to modify LDAP.
Pradeep Mishra

2007-07-26, 3:59 am

Hi

I am a beginner in perl and have tough time in writing a script which
i need urgently. I would like to know the perl script to
1)modify passswords in LDAP for multiple users taking input from
another file(which contains usernames and new passwords )
Thank you in advance.



Regards
Pradeep


--
Good Judgement comes from Experience and Experience comes from bad Judgement!!
The more I know, the more I realize I don't know!?
The easiest way to find out is to try it!!!
rcook@pcug.org.au

2007-07-26, 7:59 am

> Hi
>
> I am a beginner in perl and have tough time in writing a script which
> i need urgently. I would like to know the perl script to
> 1)modify passswords in LDAP for multiple users taking input from
> another file(which contains usernames and new passwords )
> Thank you in advance.


> --



You need a statement something like this

system("cpu usermod --password=$password $password");

For multiple users, you need to

1. Open the file with the users names/password
2. Read that file
3. loop through the above command


So I will let you tidy this up

open (my $USERS,"<", "/file/of/users-password") or die ......;
while (<$USERS> ){
chomp;
my ($user, $password) = split; #(I guess)
system("cpu usermod --password=$password $password");
}



owen





rcook@pcug.org.au

2007-07-26, 7:59 am

>> Hi
>

Oooops

One to many passwords, try


system("cpu usermod --password=$password $user");

instead


Owen
[color=darkred]
>
> You need a statement something like this
>
> system("cpu usermod --password=$password $password");
>
> For multiple users, you need to
>
> 1. Open the file with the users names/password
> 2. Read that file
> 3. loop through the above command
>
>
> So I will let you tidy this up
>
> open (my $USERS,"<", "/file/of/users-password") or die ......;
> while (<$USERS> ){
> chomp;
> my ($user, $password) = split; #(I guess)
> system("cpu usermod --password=$password $password");
> }
>
>
>
> owen
>
>
>
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>



Juan Pablo Feria Gomez

2007-07-26, 6:59 pm

>
> For multiple users, you need to
>
> 1. Open the file with the users names/password
> 2. Read that file
> 3. loop through the above command
>
>
> So I will let you tidy this up
>
> open (my $USERS,"<", "/file/of/users-password") or die ......;
> while (<$USERS> ){
> chomp;
> my ($user, $password) = split; #(I guess)
> system("cpu usermod --password=$password $password");
> }
>


Pradeep is managing his users on Ldap....

Take a look on this article...

http://www.linuxjournal.com/article/7086

You can mix Owen's script with the article examples and use
$ldap->modify($dn, replace => .... instead the system() call...

Good luck...
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com