[Samba] Listing all users in a remote Samba server
Erik Torres Serrano
erik at bioinfo.cu
Sat Apr 9 21:38:22 GMT 2005
Thanks a lot for your answer.
As a matter of security I really don't want to install network client
applications on the box. In the other hand this job is part of a new
webmin module, so the use of external commands unassociate with webmin
are not available for me :(
Regards,
Erik
Necos Secon wrote:
> If you're using perl, you could always use the backticks to get the
> output of a command. For example:
>
> my $userlist = `net rpc user -S $server -P $pass`;
>
> or
>
> my @userlist = `net rpc user -S $server -P $pass`;
>
> I forget if the net commands support passing a password to it, but if
> it does, then your job is done. Also, if I recall, the output of net
> rpc user is newline delimited, so you'll have to parse it with a
> couple of regexes. Something like this might work:
>
> my @users;
> my $go = 1;
> while ($go)
> {
> my $temp;
> $temp = ($userlist =~ m/\n/);
> my $chopper = length($temp) + 1;
> reverse($userlist);
> while ($chopper)
> {
> chop($userlist);
> $chopper--;
> }
> reverse($userlist);
> if ( length($userlist) <= 1 )
> {
> $go = 0;
> }
> }
>
> Untested and I know the algorithm could be a lot better. But, maybe
> this'll give you some direction.
>
> Theodore Charles III
> Network Administrator
> Los Angeles High School
>
More information about the samba
mailing list