1

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 user1@test.com 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. user1@anotherdomain.com. 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.

4

1 回答 1

4

这是一种不常见的做法,是否有任何特定原因是基于电子邮件而不是用户名创建用户?无论如何,这里有一些想法。

  • 使用正常的命名冲突解决方案,在 url user_domain 中包含域,
  • 如果发生冲突,则创建唯一 ID user_1, user_2 并检查下划线后的数字以生成下一个。

编辑

根据您的编辑,您可以在 moss 本身中配置冲突解决方案,这就是为什么我说这是一种创建 url 的奇怪方式,

在您的 SSP 中,转到 MySite 设置,查看站点命名格式

您的选择:

于 2009-12-08T12:50:49.467 回答