Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
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 May 3 '12 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 May 4 '12 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 May 4 '12 at 14:09

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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