fantastic work!..but a few bugs

Mar 24, 2013 at 12:17 AM
This is a good effort. I have started implementing it. I was hoping the default UserId was a Mongo.Bson.ObjectId rather than a long type.

In addition, I had to add the 'type' key on to the example config to make it work as it kept 'failing to load the assembly type':

<membership defaultProvider="MongoMembershipProvider">
    <clear />
    <add name="MongoMembershipProvider" type="ExtendedMongoMembership.MongoMembershipProvider, ExtendedMongoMembership" connectionStringName="mongoMembershipDb" />
<roleManager enabled="true" defaultProvider="MongoRoleProvider">
    <clear />
    <add name="MongoRoleProvider" type="ExtendedMongoMembership.MongoRoleProvider, ExtendedMongoMembership" connectionStringName="mongoMembershipDb" />
Mar 24, 2013 at 1:44 AM
Edited Mar 24, 2013 at 2:21 AM
Found another possible bug:

Roles.DeleteRole("testrole_351"); <-- throws an error

NotSupportedException - Unable to determine the serialization information for the expression: Enumerable.Where<MembershipRole>(u.Roles, (MembershipRole r) => (r.RoleName == "testrole_351")).

Has this solution had a full test suite ran against all the inbuilt functions in 'System.Web.Security'?...I've just spent all week replacing my current solution so it could use this :(

......20mins later

Membership.CreateUser("testuser", "testpass"); <--- NotSupportedException-Specified method is not supported

Maybe I'm doing something wrong?
Mar 24, 2013 at 9:43 AM
Edited Mar 24, 2013 at 9:45 AM

Thanks very much for contacting me. I would try to help you with this.
One by one
  1. Roles.DeleteRole("testrole_351"); <-- throws an error . I will take a look and fix if anything wrong
  2. Membership.CreateUser("testuser", "testpass"); <--- NotSupportedException-Specified method is not supported. This is right. This is implementation of new ExtendedMembershipProvider for ASP.NET MVC4. To use it power you need to work with WebSecurity class(instead of Membership). More reference here
  3. Thanks for pointing to error in my docs
  4. It uses int as id b/c new membership provider requires that.
Please let me know if you need more assistance.

Mar 24, 2013 at 5:49 PM
Edited Mar 24, 2013 at 5:55 PM
Thanks for getting back to me so quickly and the link, Dmitriy.

I'm actually trying to implement your solution into a very basic WCF service (something with username authentication using only basicHttpBinding) but I'm having difficulty. I can see the example solution uses MVC and initializes in the startup but I'm not sure where to place the initialization in a WCF. I know this is very cheeky but do you have a very basic WCF example?

_You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an AppStart.cshtml file in the root of your site. Source = WebMatrix.WebData
Mar 24, 2013 at 9:53 PM

I have fixed delete role method. You can get it from latest commit or nuget.

You dont needd to call WebSecurity.InitializeDatabaseConnection b/c we use mongodb and it makes things easier. I dont understand what exactly you want with wcf.

BTW: Standard Membership configuration site will not work any more with new membership provider and with this one as well.

Mar 28, 2013 at 2:00 AM
Edited Mar 28, 2013 at 2:39 AM
Thanks for update Dimtriy.

I'm trying to get ASP.Net Forms Authentication working in my WCF ('m just experimenting...think I will try with ServiceStack later :P

• In your downloadable zip file, the App_Data folder is corrupt and the Samples project is unable to load. I just deleted and recreated this folder. (Maybe its my extraction process using peazip that's breaking it).

• Also, using the sample project: if I attempt to login with a registered user but with incorrect password then it should update the 'LastPasswordFailureDate' field but at the moment it's updating the 'LastLoginDate' field - not correct - user login failed and so did not login successfully.

• line 702 in SimpleMongoProvider.cs : failure.PasswordFailuresSinceLastSuccess != null........ integers can never be nulls (maybe i missed something here)?

Anyway, I will keep you posted on anything interesting that I may discover whilst using your wonderful solution. BTW: this man has done lots of interesting stuff with SimpleMembership (web api authentication, decoupling layers, email confirmation, etc) but not Mongo'd it:
Mar 28, 2013 at 2:06 AM
Must be your extraction tool or your download.
I just downloaded it and it extracted without errors.
Mar 28, 2013 at 7:49 AM
Edited Apr 1, 2013 at 7:44 AM
  • I have just downloaded sources and everything worked fine as NTTAKR stated as well.
  • Thanks again for pointing to bug. Will fix it today
Very much thanks for your help(I think we are close to first release). I have took a look at Кеvin's blog, looks impressive. How do you think what is more important for version 2: add permissions or add some admin interface for managing users and roles (something like)?

Thanks, i appreciate your help,
Apr 1, 2013 at 7:53 AM

You can get updated code with fixed issues from source control.

Apr 24, 2013 at 9:45 PM

Nice work on the library. I was trying to register with OAuth provider and I noticed that:
"private MembershipAccount GetUser(string userName)"
"throw new MembershipCreateUserException(MembershipCreateStatus.InvalidUserName);"
if the user is not found with the username. This is used in CreateOrUpdateOAuthAccount to find out if user is already registered and I think it should return null if user is not found for the OAuthAccount creation to work properly.

Apr 24, 2013 at 9:52 PM
Thanks Tuomas,

Logic is right there. Why it tthrows exception because when you are trying to create OAuthAccount or usual Account User must be already created.
About method: this method is used in many places and must throw exception in all that places.

Please let me know if you have any more questions.