Given the following situation:
Within our company's farm the creation of MySites / PersonalSites is limited to members of a special AD Group ("MysiteCreator").
This group has been given the following permissions within the User Profile Service:
All the other, "casual" users are not permitted to create a MySite / Personal Site.
Now I'm wondering how to check by code if the current user is permitted to create a personal site and then create it on demand.
I've read some posts about checking the UserProfile.PersonalSiteCapabilities == "14"
(see here and here). So I wrote this piece of code:
internal bool EnsurePersonalSite()
{
UserProfileManager upm = new UserProfileManager(SPServiceContext.Current);
UserProfile up = upm.GetUserProfile(true);
// User not permitted (?) to create personal site
if ((up.PersonalSiteCapabilities & PersonalSiteCapabilities.Social)
!= PersonalSiteCapabilities.Social)
{
return false;
}
// User permitted ==> create personal site
up.CreatePersonalSiteEnque(true);
return false;
// Creation ongoing
if (up.PersonalSiteInstantiationState != PersonalSiteInstantiationState.Created
|| up.PersonalSite == null)
{
return false;
}
return true;
}
The casual user has a PersonalSiteCapabilities == 0
entry in his user profile (shown in Central Administration). Adding the user to the "MysiteCreator" AD group does not change this value to 14 and my code will always return false
.
If I would set PersonalSiteCapabilities = 14
for all users my code will always return true
no matter if the user is member of the AD Group "MysiteCreator" or not.
So what's the best, safest way to ensure a MySite / Personal Site for users only belonging to a special AD group?
PersonalSiteCapabilities
should have been set to14
for all users (profiles) belonging to the special AD group, right?