[Samba] Listing all users in a remote Samba server

Necos Secon secon_kun at hotmail.com
Sat Apr 9 21:25:02 GMT 2005

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`;


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;
  while ($chopper)
  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

&gt;From: Erik Torres Serrano &lt;erik at bioinfo.cu&gt;
&gt;Reply-To: erik at bioinfo.cu
&gt;To: samba at lists.samba.org
&gt;Subject: Re: [Samba] Listing all users in a remote Samba server
&gt;Date: Sat, 09 Apr 2005 15:02:22 -0400
&gt;Paul Gienger wrote:
&gt;&gt;&gt;I'm trying to develop a service for retrieving the entire user
&gt;&gt;&gt;list of a remote samba server. The expected result is the same
&gt;&gt;&gt;expected from the use of the samba command:
&gt;&gt;&gt;net rpc user
&gt;&gt;Depending on your backend, there's several ways to go about it,
&gt;&gt;including querying LDAP for the entries with an appropriate filter
&gt;&gt;and parsing the smbpasswd file.  I believe you could also get some
&gt;&gt;info out of pdbedit, but that could be a bit tedious.
&gt;&gt;What is your backend?
&gt;Ok, what I have is a standalone Samba server without ADS or LDAP.
&gt;Users are managed in a smbpasswd file. In the other side I have a
&gt;Linux box running webmin. Both servers are in the same LAN. What I
&gt;need is an App to be included in webmin (that's why I need Perl) in
&gt;the second box for listing all users in the Samba server.
&gt;I saw that net command use a RPC request but I didn't find how to do
&gt;the same.
&gt;That's all I have :(
&gt;To unsubscribe from this list go to the following URL and read the
&gt;instructions:  https://lists.samba.org/mailman/listinfo/samba

More information about the samba mailing list