Sharepoint PeopleEditor:如何找出返回的用户/组类型?

编程入门 行业动态 更新时间:2024-10-24 14:17:00
本文介绍了Sharepoint PeopleEditor:如何找出返回的用户/组类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个 PeopleEditor:

I have a PeopleEditor:

<SharePoint:PeopleEditor ID="peopleEdit" ... SelectionSet="User,DL,SecGroup,SPGroup" />

它在页面上完美运行,即我可以选择 AD 用户、Sharepoint 组和任何我想要的.

It works flawlessly on the page, i.e. I can select AD users, Sharepoint groups and anything I would like.

问题是我在 PeopleEditor 上找不到返回什么样的用户/组的属性.我们来看下面的例子:

The problem is that I can't find a property on the PeopleEditor of what kind of user/group is returned. Let's take the following example:

//User: John Doe - mycompany\jondoe is at position 0 //Sharepoint group: "All Site Users" is at position 1 PickerEntity pickerEntity1 = (PickerEntity).peopleEdit.ResolvedEntities[1]; // pickerEntity1.Key = "All Site Users" // pickerEntity1.Claim = null // pickerEntity1.DisplayText = "All Site Users" PickerEntity pickerEntity0 = (PickerEntity).peopleEdit.ResolvedEntities[0]; // pickerEntity1.Key = "mycompany\jondoe" // pickerEntity1.Claim = null // pickerEntity1.DisplayText = "Doe, John"

我可以做一些hackish"的事情,比如尝试将返回的字符串 [sic] 值转换为用户或组,并执行某种基于异常的程序流(如果用户存在,则执行此操作,否则如果组存在等.),但我不会考虑干净的代码.

I can do some "hackish" things like trying to cast the returned string [sic] value as a User or as a Group and do some kind of Exception based program flow (if user exists do this, else if group exist etc.), but I wouldn't consider that clean code.

是否有更好的方法在 Sharepoint 中选择人员/组或使用 PeopleEditor 的更好方法?

推荐答案

使用 EntityData 哈希表中的 PrincipalType 值:

Use the PrincipalType value from the EntityData hashtable:

string principalType = pickerEntity1.EntityData["PrincipalType"].ToString();

我不记得所有可能的值,但 User 和 SharePointGroup 肯定在其中.

I don't remember all possible values but User and SharePointGroup are definitely among them.

moontear的评论:

要列出该实体的所有信息,EntityDataElements 数组很有帮助.对于 SPGroup,它包含 SPGroupID、AccountName、PrincipalType.

To list all information this entity has, the EntityDataElements array is helpful. For SPGroup this contains SPGroupID, AccountName, PrincipalType.

Janis Veinbergs 的评论:

可能是它包含来自 Microsoft.SharePoint.Utilities.SPPrincipalType 枚举的值,但我还没有测试过.

It could be that it contains values from Microsoft.SharePoint.Utilities.SPPrincipalType enum but i haven't tested it.

给你:

[Flags] public enum SPPrincipalType { None = , User = 1, DistributionList = 2, SecurityGroup = 4, SharePointGroup = 8, All = SharePointGroup | SecurityGroup | DistributionList | User, }

更多推荐

Sharepoint PeopleEditor:如何找出返回的用户/组类型?

本文发布于:2023-11-12 12:42:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581523.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类型   用户   Sharepoint   PeopleEditor

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!