Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Get list of uses from system.users

Received: by 10.58.229.232 with SMTP id st8mr9870650vec.34.1352928289850;
        Wed, 14 Nov 2012 13:24:49 -0800 (PST)
X-BeenThere: mongodb-user@googlegroups.com
Received: by 10.220.7.200 with SMTP id e8ls1106750vce.9.gmail; Wed, 14 Nov
 2012 13:24:22 -0800 (PST)
Received: by 10.52.30.225 with SMTP id v1mr638217vdh.20.1352928262508;
        Wed, 14 Nov 2012 13:24:22 -0800 (PST)
Date: Wed, 14 Nov 2012 13:24:21 -0800 (PST)
From: Stephen Lee <stephen....@10gen.com>
To: mongodb-user@googlegroups.com
Message-Id: <7bbf3b5e-98cc-47cb-a3ea-3313b72c73f2@googlegroups.com>
In-Reply-To: <a6c77270-2a6f-4f7c-9432-7c5be69c5cdf@googlegroups.com>
References: <a6c77270-2a6f-4f7c-9432-7c5be69c5cdf@googlegroups.com>
Subject: Re: Get list of uses from system.users
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1113_12779355.1352928261806"

------=_Part_1113_12779355.1352928261806
Content-Type: multipart/alternative; 
	boundary="----=_Part_1114_713220.1352928261806"

------=_Part_1114_713220.1352928261806
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Andre,

I created a simple Mongo instance on my machine, created a "super" user in 
the admin database, and created a "hello" user (eg. 
b.getSiblingDB("testone").addUser("hello","world")) in the testone database.

    coll = my_db.collection( 'system.users' )
    coll.find.each { |doc| puts "user: #{doc[ 'user' ]}, readOnly: #{doc[ 
'readOnly' ]}" }

I do see the testone.system.users collection and was successful in 
outputting a list of users.  Could you try my sample code?  What errors do 
you see?

What version of the Ruby driver and MongoDB are you using?

-Stephen

On Thursday, November 1, 2012 3:04:28 PM UTC-4, Andre Pollard wrote:
>
> i have authentication enabled 
> i am using a ruby script
>
> i can connect to the admin db
> switch to my testone db
> list the collections where i see the system.users collection
> but can't get the users after that
>
> code
> ============
> require 'rubygems'
> require 'mongo'
>
> conn = Mongo::Connection.new("avenger", 10001 )
> puts "connection:#{conn.inspect}"
>
> conn.db('admin').authenticate("super","superpassword")
> puts "connection:#{conn.inspect}"
>
> master_status = conn.db('admin').command({'isMaster'=>1})
> puts "master_status:#{master_status}"
>
>
> if master_status['ismaster'] 
>
> my_db = conn.db('testone')
> puts "switch to my_db: #{my_db.inspect}"
>
> my_db.collection_names
> puts "my_db collections :#{my_db.collection_names.inspect}"  #get 
> ["system.indexes", "testone_collection", "system.users"]
>  # how do i run the equivalent of db.system.users.find(), tried several 
> things but to no luck
> else
>   puts "Not master"
> end
>

------=_Part_1114_713220.1352928261806
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Andre,<div><br></div><div>I created a simple Mongo instance on my machine, =
created a "super" user in the admin database, and created a "hello" user (e=
g. b.getSiblingDB("testone").addUser("hello","world")) in the testone datab=
ase.<div><br></div><div><div>&nbsp; &nbsp; coll =3D my_db.collection( 'syst=
em.users' )</div><div>&nbsp; &nbsp; coll.find.each { |doc| puts "user: #{do=
c[ 'user' ]}, readOnly: #{doc[ 'readOnly' ]}" }</div></div><div><br></div><=
div>I do see the testone.system.users collection and was successful in outp=
utting a list of users. &nbsp;Could you try my sample code? &nbsp;What erro=
rs do you see?</div><div><br></div><div>What version of the Ruby driver and=
 MongoDB are you using?</div><div><br></div><div>-Stephen<br><br>On Thursda=
y, November 1, 2012 3:04:28 PM UTC-4, Andre Pollard wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;">i have authentication enabled&nbsp;<div>i am us=
ing a ruby script</div><div><br></div><div>i can connect to the admin db</d=
iv><div>switch to my testone db</div><div>list the collections where i see =
the system.users collection</div><div>but can't get the users after that</d=
iv><div><br></div><div>code</div><div>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<=
/div><div><div>require 'rubygems'</div><div>require 'mongo'</div><div><br><=
/div><div>conn =3D Mongo::Connection.new("<wbr>avenger", 10001 )</div><div>=
puts "connection:#{conn.inspect}"</div><div><br></div><div>conn.db('admin')=
.authenticate(<wbr>"super","superpassword")</div><div>puts "connection:#{co=
nn.inspect}"</div><div><br></div><div>master_status =3D conn.db('admin').co=
mmand({'<wbr>isMaster'=3D&gt;1})</div><div>puts "master_status:#{master_<wb=
r>status}"</div><div><br></div><div><br></div><div>if master_status['ismast=
er']&nbsp;</div><div><br></div><div><span style=3D"white-space:pre">=09</sp=
an>my_db =3D conn.db('testone')</div><div><span style=3D"white-space:pre">=
=09</span>puts "switch to my_db: #{my_db.inspect}"</div><div><br></div><div=
><span style=3D"white-space:pre">=09</span>my_db.collection_names</div><div=
><span style=3D"white-space:pre">=09</span>puts "my_db collections :#{my_db=
.collection_names.<wbr>inspect}" &nbsp;#get ["system.indexes", "testone_col=
lection", "system.users"]</div><div><span style=3D"white-space:pre">=09</sp=
an></div><div><font color=3D"#ff0000"><span style=3D"white-space:pre">=09</=
span># how do i run the equivalent of db.system.users.find(), tried several=
 things but to no luck</font></div><div>else</div><div>&nbsp; puts "Not mas=
ter"</div><div>end</div></div></blockquote></div></div>
------=_Part_1114_713220.1352928261806--

------=_Part_1113_12779355.1352928261806--