var strCheckLoggedUser="";
var strCurrentUserName="";
function CheckAdminGroup()
{
var currentContext = new SP.ClientContext();
strCurrentUserName= currentContext.get_web().get_currentUser();
currentContext.load(strCurrentUserName);
var groupCollection = currentContext.get_web().get_siteGroups();
var _group = groupCollection.getById(3);
//Note:- Here 3 is the Admin Group ID.
strCheckLoggedUser= _group.get_users();
currentContext.load(strCheckLoggedUser);
currentContext.executeQueryAsync(Function.createDelegate(this, this.UserAvailableinAdminGroup), Function.createDelegate(this, this.UserNotAvailableinAdminGroup));
}
function UserAvailableinAdminGroup()
{
debugger;
var strValidUser=false;
var listEnumerator = strCheckLoggedUser.getEnumerator();
while (listEnumerator.moveNext())
{
var item = listEnumerator.get_current();
if (strCurrentUserName.get_loginName() == item.get_loginName())
{
strValidUser=true;
break;
}
}
if(strValidUser==true)
{
//Write your Functionality what u want to perform if the user logged in is a Admin User
alert('Logged in user is Admin User');
}
}
function UserNotAvailableinAdminGroup()
{
}
ExecuteOrDelayUntilScriptLoaded(CheckAdminGroup, "sp.js");
var strCurrentUserName="";
function CheckAdminGroup()
{
var currentContext = new SP.ClientContext();
strCurrentUserName= currentContext.get_web().get_currentUser();
currentContext.load(strCurrentUserName);
var groupCollection = currentContext.get_web().get_siteGroups();
var _group = groupCollection.getById(3);
//Note:- Here 3 is the Admin Group ID.
strCheckLoggedUser= _group.get_users();
currentContext.load(strCheckLoggedUser);
currentContext.executeQueryAsync(Function.createDelegate(this, this.UserAvailableinAdminGroup), Function.createDelegate(this, this.UserNotAvailableinAdminGroup));
}
function UserAvailableinAdminGroup()
{
debugger;
var strValidUser=false;
var listEnumerator = strCheckLoggedUser.getEnumerator();
while (listEnumerator.moveNext())
{
var item = listEnumerator.get_current();
if (strCurrentUserName.get_loginName() == item.get_loginName())
{
strValidUser=true;
break;
}
}
if(strValidUser==true)
{
//Write your Functionality what u want to perform if the user logged in is a Admin User
alert('Logged in user is Admin User');
}
}
function UserNotAvailableinAdminGroup()
{
}
ExecuteOrDelayUntilScriptLoaded(CheckAdminGroup, "sp.js");
No comments:
Post a Comment