The method Roles.GetRolesForUser throws an error
Exception of type 'System.ArgumentException' was thrown.
Parameter name: encodedValue
string userIdentityName = "0#.w|<domain name>\\" + username;
http://go4answers.webhost4life.com/Example/custom-role-provider-138386.aspx
Exception of type 'System.ArgumentException' was thrown.
Parameter name: encodedValue
Below post helped me understand cause of the error, it was resolved after attaching 0#
.w|<Domain Name>\\ to the user name
Reference
http://go4answers.webhost4life.com/Example/custom-role-provider-138386.aspx
Ironically Roles.AddUserToRole(userName, roleName) does not need this modification and it can work only with
the user name, thus finally though first statement is working, second is still failing because user in GetRolesForUser is different that the user in AddUserToRole method.
After some efforts I found out that solution is to use
bool isuserinrole = Roles.IsUserInRole(userName, roleName);
After some efforts I found out that solution is to use
string[]
usersinrole = Roles.GetUsersInRole(roleName);
orbool isuserinrole = Roles.IsUserInRole(userName, roleName);
these two methods return the same user as AddUserToRole method.
I need to check if below solution works.
http://blog.mastykarz.nl/notetoself-custom-membership-role-providers-sharepoint-2010-claims/
I need to check if below solution works.
http://blog.mastykarz.nl/notetoself-custom-membership-role-providers-sharepoint-2010-claims/
No comments:
Post a Comment