SharePoint MySites URL Conflict

1.5k views Asked by At

A user logins into the SharePoint site we have created using their email address and this becomes their username. However this creates a problem for MySites.

When the user creates a MySite the URL it cuts of anything after the @ symbol in the username, so if the users email address is [email protected] the URL to their MySite becomes:

http://host/personal/user1/

However this causes a problem if their is another user with the same email prefix but with a different domain i.e. [email protected]. This users MySite URL also needs to be

http://host/personal/user1/

When the user signs up to the site we create their profile and MySite using this code:

if (!profileManager.UserExists(username))
{
  UserProfile profile = profileManager.CreateUserProfile(username);
  profile["PreferredName"].Value = fullname!=null?fullname:username;
  profile["WorkEmail"].Value = email != null ? email : "";
  profile["PersonalSpace"].Value = email;
  profile.Commit();
  #region create User My Site
  using (SPSite site = profile.PersonalSite)
  {
    if (site == null)
    {
      try
      {
        profile.CreatePersonalSite();
      }
      catch (Exception ex)
      {                                           
        System.Diagnostics.Trace.WriteLine(string.Format("CreateMySite - {0}", ex.Message));
        throw ex;
      }
    }
  }
  #endregion
}
HttpContext.Current = httpCxt;

Is there something I can do here to control the URL used?

-- edit

The above behaviour is default for MOSS. I.e. I am not manually taking of the users email address, this is something the MOSS is doing automatically. I would prefer it if I could say the URL should be:

http://host/personal/user1-at-test-dot-com 

I have tried escaping the email address and assigning it to the personal space value like so:

string clean = email.Replace("@","-at-");
profile["PersonalSpace"].Value= clean;

....

but this hasn't helped.

1

There are 1 answers

1
Francisco Aquino On BEST ANSWER

This is an uncommon way of doing it, is there any specific reason the users are created based on the email not the username? Anyway, here's a few ideas.

  • Use normal naming conflict solutions, include the domain in the url user_domain,
  • create an unique Id user_1, user_2 if a conflict happens and check what number is after the underscore to generate the next one.

edit

Based on your edit, you can configure the conflict resolution in moss itself, that's why I said it was a weird way of creating the urls,

In your SSP, go to MySite Settings, look at the Site Naming Format group

Your options: