Issue with ASP .NET Profile Provider in WPF program
Issue with ASP .NET Profile Provider in WPF program
I've been working the past couple of days to get the Devart ASP .NET profile provider working in my WPF program. For various reasons, this program cannot use a Windows service to access an authentication system. My program needs to use the Profile Provider to retrieve and update all user profile information directly.
I managed to get my code to the point where it generated a custom profile object descended from ProfileBase (had to find out how to use the inherits attribute in the app.config) but now I'm getting another error.
The Devart database is using a varchar to hold the user ID in the aspnet_Users table. The User ID value is actually a UUID ( aka a GUID ), however. When I call the profile object's Save method to write the profile back to the database, the devart code is using a case-sensitive match on the UserId column. The hex digits in the UserID are stored in the UserId column in upper case; however, it tries to join on the UserId column using the same hex value, but all letters in the ID are in lower case. The inner exception of the exception I get reads: "{"insert or update on table \"aspnet_profiles\" violates foreign key constraint \"aspnet_profiles_userid_ref\""}".
How do I fix this? Can I just change the data type of all UserId columns to UUID? I suspect the fix isn't that easy. Do I need to convert all alpha hex characters in the UUIDs to lower case?
All help is appreciated.
I managed to get my code to the point where it generated a custom profile object descended from ProfileBase (had to find out how to use the inherits attribute in the app.config) but now I'm getting another error.
The Devart database is using a varchar to hold the user ID in the aspnet_Users table. The User ID value is actually a UUID ( aka a GUID ), however. When I call the profile object's Save method to write the profile back to the database, the devart code is using a case-sensitive match on the UserId column. The hex digits in the UserID are stored in the UserId column in upper case; however, it tries to join on the UserId column using the same hex value, but all letters in the ID are in lower case. The inner exception of the exception I get reads: "{"insert or update on table \"aspnet_profiles\" violates foreign key constraint \"aspnet_profiles_userid_ref\""}".
How do I fix this? Can I just change the data type of all UserId columns to UUID? I suspect the fix isn't that easy. Do I need to convert all alpha hex characters in the UUIDs to lower case?
All help is appreciated.
Mixed results
I changed the data types of the UserId & RoleId columns to UUID as you suggested. I then tried creating a new user by calling the Membership.CreateUser method. That worked on the first call.
However, trying to call Membership.GetUser( "Username" ) for an existing user throws an exception that reads, "Unable to cast object of type 'System.Guid' to 'System.String'". This is a very big problem as it prevents existing users from logging back in. Oddly, I can create new users without issue, but I can't retrieve them after they're created!
I was afraid that this was going to be the issue with the existing provider, as you're undoubtedly calling PgSqlDataReader.GetString() to retrieve the UserId from the tables. The surprise is that you can create new users without a problem.
I'm going to change the columns back into VARCHARs. We'll just have to do a conversion to lower case when inserting user data from an outside source into the membership provider tables. Unless you guys release a new version that uses Guids in the database and in the provider code.
Tony
However, trying to call Membership.GetUser( "Username" ) for an existing user throws an exception that reads, "Unable to cast object of type 'System.Guid' to 'System.String'". This is a very big problem as it prevents existing users from logging back in. Oddly, I can create new users without issue, but I can't retrieve them after they're created!
I was afraid that this was going to be the issue with the existing provider, as you're undoubtedly calling PgSqlDataReader.GetString() to retrieve the UserId from the tables. The surprise is that you can create new users without a problem.
I'm going to change the columns back into VARCHARs. We'll just have to do a conversion to lower case when inserting user data from an outside source into the membership provider tables. Unless you guys release a new version that uses Guids in the database and in the provider code.
Tony
New version of dotConnect for PostgreSQL 5.50 is released!
It can be downloaded from http://www.devart.com/dotconnect/postgr ... nload.html (trial version) or from Registered Users' Area (for users with valid subscription only): http://secure.devart.com/ .
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=21944 .
It can be downloaded from http://www.devart.com/dotconnect/postgr ... nload.html (trial version) or from Registered Users' Area (for users with valid subscription only): http://secure.devart.com/ .
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=21944 .
Looks good!
I have downloaded and installed the 6-Sep-2011 version of the dotConnect libraries. Now that my problem with access a version 9.0.4 server with the new DLLs is fixed, I've updated the table designs to use UUIDs for the UserId and RoleId columns in the aspnet_Xxxx tables.
I'm happy to report that all code is working 100%. Thanks!
Tony
I'm happy to report that all code is working 100%. Thanks!
Tony