/// <summary>
        /// 从人员选择器中取值
        /// </summary>
        /// <param name="peopleEditor"></param>
        /// <returns></returns>
        public static List<SPPrincipal> GetSPPrincipalsFromPeopleEditor(PeopleEditor peopleEditor)
        {
            List<SPPrincipal> rtn = new List<SPPrincipal>();
            SPWeb web = SPContext.Current.Web;
            SPUserCollection users = web.SiteUsers;
            SPGroupCollection groups = web.SiteGroups;
            foreach (PickerEntity pe in peopleEditor.ResolvedEntities)
            {
                string principalType = pe.EntityData["PrincipalType"].ToString();
                if (principalType == "User" || principalType == "SecurityGroup")
                {
                    string loginName = pe.Key;
                    foreach (SPUser u in users)
                    {
                        if (u.LoginName == loginName)
                        {
                            rtn.Add(u);
                            break;
                        }
                    }
                }
                string groupName = pe.Key;
                foreach (SPGroup g in groups)
                {
                    if (g.Name == groupName)
                    {
                        rtn.Add(g);
                        break;
                    }
                }
            }
            return rtn;
        }

相关文章:

  • 2022-12-23
  • 2021-08-03
  • 2022-01-21
  • 2021-11-20
  • 2022-12-23
  • 2021-08-24
  • 2021-11-16
  • 2021-07-14
猜你喜欢
  • 2021-07-10
  • 2021-11-19
  • 2021-08-08
  • 2022-12-23
相关资源
相似解决方案