0

I am trying to get Public URL of all my sites. i have ran this code for every loginname and its working fine except for one user. for this user i am getting null in up.PersonalSite. i have checked it manually and mysite for that user exists. any ideas why up.personalsite is returning null. any suggestions?

SPServiceContext context = SPServiceContext.GetContext(Site);
UP.UserProfileManager upm = new UP.UserProfileManager(context);
UP.UserProfile up = upm.GetUserProfile(LoginName);
 if (up.PersonalSite == null)
    return "#";
 else
    return up.PublicUrl.OriginalString;
Raheel
  • 595
  • 8
  • 21
  • also i noticed in central administration that i have site collection for every user but not for this one. what does it mean. i dont know much about mysite feature. please help. – Raheel Aug 06 '12 at 23:15

1 Answers1

0

Maybe, you saw Profile pages for existing users? (http://localhost/my/Person.aspx?accountname=DOMAIN%5CVPupkin) The user should create your site itself or you can create programmatically with

SPServiceContext context = SPServiceContext.GetContext(Site);
UP.UserProfileManager upm = new UP.UserProfileManager(context);
UP.UserProfile up = upm.GetUserProfile(LoginName);
up.CreatePersonalSite();
moskalevN
  • 348
  • 5
  • 11
  • After User Profile Sync Personal Sites are created automatically, but if you created User Profile manually, then you should create Personal Site manually too. – moskalevN Aug 07 '12 at 06:56