I am new to ASP.NET MVC Forms Authentication and have just started to create my own Custom Membership Provider. My ValidateUser and ChangePassword methods work but now I want to use the GetUser method to return the current user's data throughout my site. My AX method returns an AxaptaRecord which contains details of the user, like their phone number, company name etc.. How would I use this with the GetUser method?
Asked
Active
Viewed 307 times
2 Answers
1
You just need to create a new instance of MembershipUser object and populate properties from the AxaptaRecord object, here is some pseudocode:
MembershipUser user = new MembershipUser("AX",
(string)axRecord.get_Field("name"),
axRecord.get_Field("recid"),
email, //get this from SysUserInfo table
string.Empty,
string.Empty,
(bool)axRecord.get_Field("enable"),
!(bool)axRecord.get_Field("enable"),
(DateTime)Convert.ChangeType(axRecord.get_Field("createdDateTime"), typeof(DateTime)),
DateTime.MinValue,
DateTime.MinValue,
DateTime.MinValue,
DateTime.MinValue);
Then you return user from your GetUser method. See the GetUser method description here: http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx

armasanea
- 434
- 3
- 7
0
Controller:
var userDetails = System.Web.Security.Membership.GetUser(username);
Then, there are many different ways for you to pass the data to View. Each way has its advantage and disadvantage. For details, please click here.
Model strongly-typed view can let you easily handle validation and generate data but not very good in display data if you have more than one table.

Community
- 1
- 1

DragonZelda
- 168
- 1
- 2
- 12
-
But in my Membership.GetUser() method I'm returning an AxaptaRecord datatype, not a MembershipUser datatype. – CallumVass Feb 09 '12 at 09:24
-
I'm not sure if using my Custom Membership Provider to do this is the best way. I think a better way might be to store the value's returned in a session variable – CallumVass Feb 09 '12 at 09:25