Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Thursday, January 31, 2013

Check Whether the Logged User is Admin or Not using JQuery & SharePoint Default WebServices


1. First Place one Login Control within a Master Page and Take IT's ID from the View Source of the Page.
2. Download the SPAPI_Core.JS File
3. Download the SPAPLI_UserGroup.JS File

var strSiteUrl="http://SPSERVER:100";
var objGroup=new SPAPI_UserGroup(strSiteUrl);


function checkAdminUser()
{
   var strValidUser=false;
    var strCurrentUser=$("#ctl00_lgnUser").html();
    var ug1 = objGroup.getGroupCollectionFromUser(strCurrentUser);
    $(ug1.responseXML).find("Group").each(function()
    {
         if($(this).attr("ID")==3)
         {
             strValidUser=true;
         }
   
    });
   
    if(strValidUser==true)
    {
        alert('The User Logged is Admin User');
    }
}

$(document).ready(function()
{
    checkAdminUser();
});

No comments:

Post a Comment