When granting permission to an individual or a group within SharePoint 2010 picker picker is used to identify then pick the person or group. Identifying is based on the display text shown to the user in a table format. This display text may not be enough for the user to identify the person correctly. This is when the list view of the people picker could be used to distinguish the picker entities a bit more. This requires filling in additional attribute values when generating picker entity from SPClaimProvider.
Details vs List View :
Above picture show the email address field filled in during picker entity creation from SPClaims provider. This is infact very easy to do. Here is how, i will provide code snippet for both a User entity and Group entity.
For User picker entities,
private PickerEntity CreatePickerEntityFromUserProfile(UserProfile profile)
{
PickerEntity entity = CreatePickerEntity();
entity.Key = profile.PrincipalName;
entity.DisplayText = profile.Fullname;
entity.Description = profile.PrincipalName;
if (string.IsNullOrEmpty(entity.DisplayText))
{
entity.DisplayText = profile.PrincipalName;
}
entity.Description = profile.PrincipalName;
entity.EntityData[UserProfileEntityInfo.PrincipalName] = profile.PrincipalName;
entity.EntityData[UserProfileEntityInfo.Forenames] = profile.Forenames;
entity.EntityData[UserProfileEntityInfo.Surname] = profile.Surname;
entity.EntityData[UserProfileEntityInfo.PreferedName] = profile.PreferedName;
entity.EntityData[UserProfileEntityInfo.UPI] = profile.UPI;
entity.EntityData[UserProfileEntityInfo.PrimaryEmail] = profile.PrimaryEmail;
entity.EntityData[UserProfileEntityInfo.Fullname] = entity.DisplayText;
entity.Claim = SPClaimProviderManager.CreateUserClaim(profile.PrincipalName,
SPOriginalIssuerType.TrustedProvider, trustedProviderName);
entity.EntityType = OrganisationalEntityTypes.User;
entity.EntityGroupName = OrganisationalEntityTypes.PeopleGroup;
entity.IsResolved = true;
return entity;
}
For Group picker entities,
private PickerEntity CreatePickerEntityFromContextRole(ContextRole contextGroup)
{
PickerEntity entity = CreatePickerEntity();
entity.Key = contextGroup.ContextRoleName;
entity.DisplayText = contextGroup.ContextRoleName.ToLower();
entity.Description = entity.DisplayText;
entity.EntityData[ContextEntityInfo.Name] = entity.DisplayText;
entity.EntityData[ContextEntityInfo.PrimaryEmail] = contextGroup.Email;
entity.EntityData[ContextEntityInfo.DisplayName] = entity.DisplayText;
if (contextGroup.ContextTypeName == "Stream")
{
entity.EntityType = OrganisationalEntityTypes.Stream;
entity.EntityGroupName = OrganisationalEntityTypes.StreamGroupsGroup;
entity.Claim = new SPClaim(OrganisationalClaimTypes.StreamRole,
contextGroup.ContextRoleName, OrganisationalClaimTypes.StreamRoleValueType,
SPOriginalIssuers.Format(SPOriginalIssuerType.TrustedProvider, trustedProviderName));
}
else if (contextGroup.ContextTypeName == "Course")
{
entity.EntityType = OrganisationalEntityTypes.Course;
entity.EntityGroupName = OrganisationalEntityTypes.CourseGroupsGroup;
entity.Claim = new SPClaim(OrganisationalClaimTypes.CourseRole,
contextGroup.ContextRoleName, OrganisationalClaimTypes.CourseRoleValueType,
SPOriginalIssuers.Format(SPOriginalIssuerType.TrustedProvider, trustedProviderName));
}
entity.IsResolved = true;
return entity;
}
In the above code snippets, UserProfile and ContextRole are custom classes that hold information about User and Group respectively. You can probably tell this snippet is from a SPClaimProvider specialized for a university, so you don’t have to use all the attributes only the ones that apply to you organization. PeopleEditorEntityDataKeys class has the attribute names that are most often used withing SharePoint. UserProfileEntityInfo and ContextEntityInfo hold string constants specifying the additional column names.
public class UserProfileEntityInfo
{
public const string PrincipalName = "Principal Name";
public const string Forenames = "Forenames";
public const string Surname = "Surname";
public const string PreferedName = "Prefered Name";
public const string UPI = "UPI";
public static string Fullname
{
get
{
return PeopleEditorEntityDataKeys.DisplayName;
}
}
public static string PrimaryEmail
{
get
{
return PeopleEditorEntityDataKeys.Email;
}
}
}
public class ContextEntityInfo
{
public static string Name
{
get
{
return "Context Name";
}
}
public static string DisplayName
{
get
{
return PeopleEditorEntityDataKeys.DisplayName;
}
}
public static string PrimaryEmail
{
get
{
return PeopleEditorEntityDataKeys.Email;
}
}
}
There are couple of additional benefits to specifying these attributes. Apart from macking user and group identification easy, it lets any custom code which requires people picker to be able to use these additional attributes in its code in an implementation independent way, which is always a very good thing to do while designing new functionality. Second benefit is in regard to groups. I haven’t been able to create custom profiles for groups, however the only profile functionality i wanted for groups is email attribute. If we populate our picker entities during permission granting SharePoint will copy this email address and store it in the site collection. Thus If you did grant permissions to a group and someone wanted to send an email to this group, this is the email address that would be used. We use a distribution list email per group to full fill this requirement. Btw, if anyone else have another way of doing this please let me know, always keen to learn.



Trackback
by KENT
02 Nov 2011 at 18:19
asthmatic inhaller mask for children…
Buy_it now…
Trackback
by GEORGE
03 Nov 2011 at 12:39
office of generic drug…
Buy_generic drugs…
Trackback
by JUAN
03 Nov 2011 at 14:19
chronic bronchitis from marijuana…
Buy_now…
Trackback
by JEREMIAH
04 Nov 2011 at 01:06
decreased appetite during pregnancy…
Buy_generic drugs…
Trackback
by NATHAN
04 Nov 2011 at 06:06
hot dog hospital diet substitutions…
Buy_generic drugs…
Trackback
by KURT
04 Nov 2011 at 17:46
can a woman have colorectal cancer…
Buy_drugs without prescription…
Trackback
by ZACHARY
05 Nov 2011 at 00:26
food low in cholesterol…
Buy_now it…
Trackback
by ALFREDO
06 Nov 2011 at 14:03
ayurvedic ashwagandha zyban…
Buy_generic pills…
Trackback
by LEE
07 Nov 2011 at 11:43
allergic reaction to topical miconazole…
Buy_generic meds…
Trackback
by WADE
08 Nov 2011 at 23:37
clinical diagnosis and medical records…
Buy_generic meds…
Trackback
by FREDDIE
09 Nov 2011 at 07:57
twin pregnancy obstetrician specialist dallas…
Buy_drugs without prescription…
Trackback
by PATRICK
09 Nov 2011 at 17:57
psychotic depression and philadelphia…
Buy_generic meds…
Trackback
by ARTURO
09 Nov 2011 at 19:37
shampoo for people with dog allergies…
Buy_now…
Trackback
by DALE
10 Nov 2011 at 00:37
eye drops canine paralysis…
Buy_now…
Trackback
by IAN
12 Nov 2011 at 15:57
boniva and bone thinning and breaks…
Buy_now it…
Trackback
by REGINALD
15 Nov 2011 at 20:55
free fast diet tips…
Buy_generic meds…
Trackback
by LESLIE
16 Nov 2011 at 00:15
cause for morning erections…
Buy_generic meds…
Trackback
by CHRISTIAN
16 Nov 2011 at 13:36
inpatient drug rehab sanford fl…
Buy_it now…
Trackback
by REGINALD
17 Nov 2011 at 12:55
acyclovir stada cream…
Buy_generic drugs…
Trackback
by RAMON
10 Dec 2011 at 08:05
children@prozac.buy” rel=”nofollow”>……
Buywithout prescription…