Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kristoffer Eriksen 185 posts 465 karma points
    Aug 15, 2012 @ 13:35
    Kristoffer Eriksen
    0

    MembershipUser non-casesensitive?

    I'm managing my members through an daily import from CSV file, with some code to check what and when to update etc.

    But I've ben strugling a bit with it today, until i found out, that the Usernames from the CSV files exists multiple time, but with different casing.

    Which leeds me to the problem with using Membership.GetUser by username because AbC and ABC is the same.

    Is there any way to set that the username should be casesensitive ?

  • Sandro 45 posts 118 karma points c-trib
    Aug 15, 2012 @ 14:39
    Sandro
    0

    Assuming your import script is written in C# .NET and you have a list of email addresses you can do this:

    var data = new List { "AbC ", "aBc", "abcd" };
    var members = data.Distinct(StringComparer.CurrentCultureIgnoreCase);

    The trick is done by the LINQ Function "Distinct" - which works similar like its SQL equivalent - and the StringComparer class. I used StringComparer.CurrentCultureIgnoreCase here. But there are other options available in .NET 4.0

    Hope it helps.

  • Sandro 45 posts 118 karma points c-trib
    Aug 15, 2012 @ 14:39
    Sandro
    0

    Double post, Sorry!

  • Kristoffer Eriksen 185 posts 465 karma points
    Aug 15, 2012 @ 15:00
    Kristoffer Eriksen
    0

    Hey Sandro

    The problem is, that when I create the member, I first check if the member already exists, because then I will just update that member.

    Which means that System.Web.Security.Membership.GetUser(string username) will return the same member when searching for AbC and aBc.

    I can't create two users using the buildin Umbraco Create user wizard with username AbC and aBc, because they are "equal".

    And that is a problem for me.

  • Sandro 45 posts 118 karma points c-trib
    Aug 15, 2012 @ 15:11
    Sandro
    0

    I think this is by design. But are you sure you want Kristoffer and kristoffer being two different Users?

  • Kristoffer Eriksen 185 posts 465 karma points
    Aug 15, 2012 @ 15:23
    Kristoffer Eriksen
    0

    I dont :-)... But the site we are migrating from another CMS to Umbraco, has about 5700 members.

    And all the memberinfo is exported to a CSV file, including the username for each member. And in that list is several exampels where the username is AbC and aBc ( just examples ).

    So when I'm importing the members in the new Umbraco solution, I got a problem :-)

    But I will let it rest until the customer is back from vacation ( next week ), and then I will need to talk with him about this issue...

     

  • Sandro 45 posts 118 karma points c-trib
    Aug 15, 2012 @ 16:21
    Sandro
    0

    I haven't tried that but you can try changing the collation of the column 'userLogin' in the table 'umbracoUser' to a case sensitive collation. For example Latin1_General_CS_AS. This should do the trick, since the umbraco internal query for the GetUser() method looks like this

    select id from umbracoUser where userLogin = @login

    (Source - Ctrl+F for Method:getUserId(string lname))

    You can find instructions here, although I wouldn't recommend it as it easily could cause other problems.

    I'd recommend printing out the problematic user names and discuss them with your customer. Maybe you're doing him a favor, cleaning some of them out... You never know ;-)

Please Sign in or register to post replies

Write your reply to:

Draft