zoukankan      html  css  js  c++  java
  • SharePoint 2010 C# 获取People Or Group

    SharePoint 2010 C# 获取People Or Group

    public override void ItemDeleting(SPItemEventProperties properties)
            {
                base.ItemDeleting(properties);
                bool judge = false;
                SPListItem item = properties.ListItem;
                SPFieldUserValueCollection FieldUserValueCollection = (SPFieldUserValueCollection)item["Users"];
                SPFieldUserValueCollection fieldUserValues = new SPFieldUserValueCollection();
                if (FieldUserValueCollection != null)
                {
                    foreach (SPFieldUserValue FieldUserValue in FieldUserValueCollection)
                    {
                        if (FieldUserValue.User != null)
                        {
                            if (FieldUserValue.User.ID == SPContext.Current.Web.CurrentUser.ID)
                            {
                                judge = true;
                                break;
                            }
                        }
                        //if the field contain group
                        else
                        {
                            SPGroup group = SPContext.Current.Web.SiteGroups.GetByID(FieldUserValue.LookupId);
                            SPUser currentUser = SPContext.Current.Web.CurrentUser;
                            SPGroupCollection userGroups = currentUser.Groups;
                            foreach (SPGroup mygroup in userGroups)
                            {
                                if (group.Name == mygroup.Name)
                                    judge = true;
                                break;
                            }
                        }
    
                    }
    
                    if (judge == true)
                    {
                        properties.Cancel = true;
                        properties.ErrorMessage = "You cannot delete the file.";
                    }
    
                }
    
            }
  • 相关阅读:
    Meta http-equiv属性详解(转)
    meta
    meta viewport 详解
    jquery 常用函数
    jquery 设置css样式
    jquery 常用函数集锦
    DATEDIFF 和 DATEADD
    C# 二进制图片串互转
    C# 二进制字符串互转
    重集合中找出最相近的一个数字
  • 原文地址:https://www.cnblogs.com/ahghy/p/3103841.html
Copyright © 2011-2022 走看看