Javascript front-end to determine whether one user is the memeber of a permission group in SharePoint

last articl:Javascript front-end to start the SharePoint workflow ,Connected to a use SPservice some practice. When you need to do some low-level rights management, such as to determine whether the current user belongs to a permission group (Group) decided to display the UI. The following is the judgment function code:

function IsMemberOfGroup(strGroupName)
{
    var rt=0;
    var g_strCurrUser = "";
    $().SPServices({
            operation: "GetUserProfileByName",
            AccountName: $().SPServices.SPGetCurrentUser(),
            async: false,
            completefunc: function(xData, Status) {
        
            g_strCurrUser= $(xData.responseXML).find("Name:contains('PreferredName')").first().parent().find("Value").text();
        //alert(g_strCurrUser);
        $().SPServices({
                    operation: "GetUserCollectionFromGroup",
                    groupName: strGroupName,
                    async: false,
                    completefunc: function(xml, Status) {
                    
                            if($(xml.responseXML).find("User[Name='" + g_strCurrUser + "']").length > 0) 
                            {
                            //alert($().SPServices.SPGetCurrentUser({fieldName: "UserName"}));      
                            rt = 1;
                            }
                      
                    }
                }); /*close().SPServices({ */
            }
    }); /*close().SPServices({ */
      
    return rt;
}

First called by Jquery SharePoint webservice GetUserProfileByName "to get the user name and pass another one the webservice GetUserCollectionFromGroup" to determine whether the group members

Related Posts