Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Sharepoint PeopleEditor:如何找出返回的用户/组类型?_C#_Sharepoint_Sharepoint 2010 - Fatal编程技术网

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, 
}