3

We're having the issue where user's names shown after logging in are being preffixed with the membership provider information, e.g. i:0#.f|fbamembershipprovider|myemail@q... (note that we're using FBA rather than AD)

I've found many articles that explain how to change this in powershell, but on an individual user by user basis, so I decided to write a small C# console app to make the changes on all affected users:

static void Main(string[] args)
{
    string serverName = ConfigurationManager.AppSettings["qmServer"];
    bool performUpdates = Convert.ToBoolean(ConfigurationManager.AppSettings["qmPerformUpdates"]);
    int updatesPerformed = 0;
    int updatesRequired = 0;
    StringBuilder updatedUsers = new StringBuilder();
    using (SPSite site = new SPSite(serverName))
    {
        using (SPWeb web = site.OpenWeb("/"))
        {
            bool allowUpdates = web.AllowUnsafeUpdates;
            web.AllowUnsafeUpdates = true;
            SPUserCollection userColl = web.AllUsers;
            foreach (SPUser user in userColl)
            {
                if (user.Name.IndexOf("i:0#.f|fbamembershipprovider|") == 0)
                {
                    updatesRequired++;

                    if (performUpdates)
                    {
                        try
                        {
                            user.Name = user.Name.Replace("i:0#.f|fbamembershipprovider|", "");
                            user.Update();
                            updatesPerformed++;
                        }
                        catch { }                                
                    }
                    updatedUsers.AppendLine(user.Name);
                }
            }
            web.Update();
            web.AllowUnsafeUpdates = allowUpdates;
        }
    }
}

The problem is that while this works, the effect is only temporary. Sometime later (within 1 hour I think), the affected names are reverted back to showing the membership info.

Can anyone advise why the updates are not permanent? Is there a server (User Profile Sync?) that might be reverting the names?

Any guidance would be appreciated.

Kevin

3
  • 1
    It does seem like your user profile display name values are getting overwritten. Do you have a custom job that synchronizes users from your custom store with your sharepoint users? Or do you have some login that syncs the accounts up when users login?
    – sween_sp
    Commented May 3, 2012 at 16:16
  • As far as I am aware, no I don't. Looking through the timed jobs, I don't see anything that might cause this. Oddly this is currently only impacting 89 users out of around 80,000, though the 89 figure increases by one or two each day. I've just set one of the DisplayName's using Powershell, to see if that offers a permanent fix - if so, then there's definitely something missing from my C# script.
    – QMKevin
    Commented May 4, 2012 at 12:08
  • 1
    I may have found a timed job that has been resyncing the display name: Farm User Profile Service Proxy - User Profile to SharePoint Full Synchronization. Having disabled this (temporarily until I find out exactly what it does), I've not seen my 'fixed' display names reverting back to their former values, and it's been over an hour. So, fingers crossed! @sween_sp if you want to add an 'answer', I can mark it as such.
    – QMKevin
    Commented May 4, 2012 at 14:09

1 Answer 1

3

I found a timed job that has been resyncing the display name: Farm User Profile Service Proxy - User Profile to SharePoint Full Synchronization. Having disabled this (temporarily until I find out exactly what it does), I've not seen my 'fixed' display names reverting back to their former values.

Thanks sween_sp for the nudge in the right direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.