WebSecurity Class and Long Ids

Topics: ASP.NET Web API, ASP.NET Web Pages, General
Oct 15, 2012 at 12:39 PM

I'm looking to use the long datatype (bigint) for various id values in a system and the current implementation for the WebSecurity class makes the assumption that the UserId is an int (smallint).

I'm considering downloading the source and editing it to use long data types instead. Does anyone know if this has already been done?

Another option would be to adapt it to be generic so it could also accommodate GUID values as well.

Has anything like this been done already?

Oct 16, 2012 at 8:01 PM

Hello Mr. Jammer,

I'm not aware of anyone having done the kind of work you propose, but it should be possible.  I'm curious about your scenario, though.  Do you have an existing membership database you need to re-use?  Are you designing a solution that needs to support billions of users?

Usually, for those kinds of scenarios, we expect folks to create their own MembershipProvider and RoleProvider classes (which, incidentally, are what WebSecurity calls under the covers).  This is also likely to be much more performant under high loads.

If you think there's a scenario that's missing, let me know and I can put in a good word for getting a bug fix in.

Thanks,
Clay

Nov 3, 2012 at 4:02 PM

Hi Clay,

I'm building a system that will be producing lots of input from lots of users hence the early requirement for long ids.  It's also a case of interacting with other systems that do use long (bigints) for Ids so to some extent my hand is forced in order to not cause other problems further down the line.


What I have done is take the source for WebSecurity / SimpleMembership / SimpleRoleProvider and taken the code into my own libraries from there I have modified the code to fit my needs.  Was actually very straight forward.

 

Regards,

Nov 5, 2012 at 9:23 PM

Definitely the right approach for now. Glad it was easy to figure out! :)

Nov 5, 2012 at 10:15 PM

I'm always very cagey about messing with security related code.  Lots of testing ahead! ;)