C# Sharepoint PeopleEditor:如何找出返回的用户/组类型?
我有一个人物编辑:C# Sharepoint PeopleEditor:如何找出返回的用户/组类型?,c#,sharepoint,sharepoint-2010,C#,Sharepoint,Sharepoint 2010,我有一个人物编辑: <SharePoint:PeopleEditor ID="peopleEdit" ... SelectionSet="User,DL,SecGroup,SPGroup" /> 我可以做一些“哈希”的事情,比如把返回的字符串[SiC]值作为用户或组来做,并且做一些基于异常的程序流(如果用户存在这样做,如果组存在,等等),但是我不会考虑干净代码。< /P> 是否有更好的方法在Sharepoint中选择人员/组,或者有更好的方法使用PeopleEditor?使用Ent
<SharePoint:PeopleEditor ID="peopleEdit" ... SelectionSet="User,DL,SecGroup,SPGroup" />
我可以做一些“哈希”的事情,比如把返回的字符串[SiC]值作为用户或组来做,并且做一些基于异常的程序流(如果用户存在这样做,如果组存在,等等),但是我不会考虑干净代码。< /P>
是否有更好的方法在Sharepoint中选择人员/组,或者有更好的方法使用PeopleEditor?使用
EntityData
哈希表中的PrincipalType
值:
string principalType = pickerEntity1.EntityData["PrincipalType"].ToString();
我不记得所有可能的值,但User
和SharePointGroup
肯定在其中
发言人的评论: 要列出此实体拥有的所有信息,
EntityDataElements
数组非常有用。对于SPGroup
,它包含SPGroupID
,AccountName
,PrincipalType
发言人的评论:
它可能包含来自
Microsoft.SharePoint.Utilities.SPPrincipalType
enum的值,但我还没有测试它
给你:
[Flags]
public enum SPPrincipalType
{
None = ,
User = 1,
DistributionList = 2,
SecurityGroup = 4,
SharePointGroup = 8,
All = SharePointGroup | SecurityGroup | DistributionList | User,
}
啊,太好了!要列出此实体拥有的所有信息,可以使用
.EntityDataElements
数组。对于包含“SPGroupID”、“AccountName”、“PrincipalType”的SPGroup,它可能包含来自Microsoft.SharePoint.Utilities.SPPrincipalType
enum的值。但我还没有测试过。这就是:[Flags]公共枚举SPPrincipalType{None=,User=1,DistributionList=2,SecurityGroup=4,SharePointGroup=8,All=SharePointGroup | SecurityGroup | DistributionList | User,}
@moontear我在答案中添加了你的评论,因为它包含有价值的信息,这样更可读。@JanisVeinbergs我在答案中添加了你的评论,因为它包含有价值的信息,这样更可读。
[Flags]
public enum SPPrincipalType
{
None = ,
User = 1,
DistributionList = 2,
SecurityGroup = 4,
SharePointGroup = 8,
All = SharePointGroup | SecurityGroup | DistributionList | User,
}