[CXX-601] exception during auth Created: 13/May/15 Updated: 11/Sep/19 Resolved: 15/May/15 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | None |
| Affects Version/s: | legacy-1.0.0-rc4, legacy-1.0.0 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Judy Han [X] | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | legacy-cxx | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Red Hat Enterprise Linux Server release 6.6 (Santiago) |
||
| Description |
|
I recently added auth to my application. The related code is: ; ; From shell I am able to call auth using the above db, user, pwd: Thanks! |
| Comments |
| Comment by Judy Han [X] [ 15/May/15 ] | |||||||||||||||||||||||||||||||
|
Hi Andrew, | |||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 15/May/15 ] | |||||||||||||||||||||||||||||||
|
Hi Andrew, Thanks for reading through my code and giving precise suggestions. Sorry I made a embarassing mistake. what()=nsToCollectionSubstring: no . It seems as if it is expecting a collection substring in the URL. I printed URL before connect: > use EventAuthDatabase Please advice. Thanks! p.s. I had a small change to your code: "cs.connect(&errString)" to "cs.connect(errString)" because input parameter expect passing by reference:
p.s. Thanks for the forum link. I just got a solution to my question from | |||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 14/May/15 ] | |||||||||||||||||||||||||||||||
|
Hi Judy.Han FYI, questions like you have here are better answered by posting your questions to the mongodb-user group. You can find the group here: https://groups.google.com/forum/#!forum/mongodb-user The C++ driver team monitors that group and will respond to questions. If your question turns out to indicate a bug in the driver after discussion with us, then it makes sense to file an issue in the bug tracker. I recommend that you ask your question about authentication and roles there. It doesn't really pertain directly to the C++ driver. | |||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 14/May/15 ] | |||||||||||||||||||||||||||||||
|
Hi Judy - The return value of DBClientConnection::connect is already a DBClientBase pointer. By passing it to the constructor of DBClientConnection, you are converting that pointer to bool. The constructor of DBClientConnection then runs, but 'connect' is never called on it. As a result, the DBClientConnection you are calling _auth on is not connected. Additionally, when using ConnectionString::parse in the legacy-1.0x driver you must use MongoDB URL syntax, not the old connection string format. If you wish to use the deprecated connection string format you must call ConnectionString::parseDeprecated. The proper setup to connect vi a URL looks like:
In this case, the auth parameters can be set in the URL (see http://docs.mongodb.org/manual/reference/connection-string/), and you do not need to make a subsequent call to auth. The proper setup to connect via an old style connection string is:
Note that with the old mechanism, you must explicitly call auth since there is no way to provide auth parameters to parseDeprecated. | |||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 14/May/15 ] | |||||||||||||||||||||||||||||||
|
While we are on the topic of authorization and authentication. I have a question on authorization.
I tried to create a user with "__system" role but failed with syntax error:
How do I access db.serverStatus() when server authorization is enabled? Thanks! | |||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 14/May/15 ] | |||||||||||||||||||||||||||||||
|
Hi Andrew,
here is the code snippet:
The exception is from line 16.
my mongodb.conf is:
Both client and server are on the same host for current test. | |||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 14/May/15 ] | |||||||||||||||||||||||||||||||
|
Hi Judy.Han - Thanks for the detailed bug report. I do have some additional questions:
Also, please note that the legacy-1.0.0 driver offers support for connection URLs. Please see the documentation for the 'ConnectionString' class in dbclientinterface.h. In particular, the static function ConnectionString::parse, and the factory function ConnectionString::connect. You may find that it is easier to connect properly when using a connection URL. | |||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 13/May/15 ] | |||||||||||||||||||||||||||||||
|
sorry the format is messed up, try again:
Line 104 throws the exception. From shell I am able to call auth using the same db, user, pwd:
Thanks! |