This project is read-only.

Extending Users

Dec 7, 2008 at 12:31 PM

Could someone show me how to extend user object, without change N2 source?
Dec 7, 2008 at 9:45 PM
I don't know exactly how it would be done but you could look into ASP.NET profiles to accomplish this.
Dec 7, 2008 at 10:27 PM
Can it be done from a addin. The reason this is that I'll will make it in VB.
Dec 8, 2008 at 7:35 AM
You can use ASP.NET profiles for extending users but in that case if you want to use the out of the box Profile Provider you must use at least SQL EXPRESS database or SQL 2005/2008.
So this means that there is no out of the box provider available for MySql or SQLite. Other solution is to create your own Profile Provider which will be able to exchange data with other database/xml file.
Bare that if you start using the Profile Provider that Microsoft offers you will be a little bit limited in the searches that you can do against the users and their profiles. All data is saved as a serialized xml in one column in one of the profile tables. So if you need to search for example all users with first name, let's say 'Richard' you won't be able to do that.

Maybe it is a good idea to have something similar to the User type which N2 has in N2.Security and that can be extended by the developers...
libardo what is your suggestion for that? Maybe I could start working on a feature like that so everybody can use it afterwards... I need your opinion about this (just adding/removing properties from the User type).

Dec 8, 2008 at 8:59 AM
Hi zokizlatanov

That sounds good. I prefer to use the N2 user type. And not having to add ASP.NET profiles too.

Also the "remove role from a user" does not work at all.

Dec 8, 2008 at 9:55 PM
@zokizlatanov: Perhaps this could be accomplished by inheriting from the user class ( Either that or using the profile api:s. I havn't used them enough to give advice. Another useful feature would be some kind of UI integration (make the user registration reflect the model class without change).

@molsen: How should I reproduce remove role from user not working? How are you removing roles from a user?
Dec 9, 2008 at 8:26 AM
Hi libardo

If you add a role to a user and then try to removed it, it doesn't remove from the checkbox next time I check.
It's on the normal user page of N2.