3

When manger would like to edit the permission level he will select the user or group from user.aspx for editing their permission level using Edit Permission button.

It will show edit permission page (editprms.aspx) as shown below.

enter image description here

In that page selected user/group display name will be displayed, but here I need to retrieve corresponding user email and also other profile information in case of group I need to retrieve corresponding group ID.

0

I got a solution for my question. When Edit Permission button hit following URL will be passed to SharePoint

http://xyz:1010/sites/raja/_layouts/editprms.aspx?obj=editprms.aspx?obj=http%3a%2f%2fxyz%3a1010%2fsites%2fraja%2cWEB&sel=1&IsDlg=1

In SharePoint there is one hidden list is called SiteUserInfoList which contain the details about the users and groups have access to the current site.

From this list we can obtain the users information.

enter image description here

You can get the list ID from the given URL sel=1 is the list ID which is selected user information item id in the SiteUserInfoList.

So using below javascript code you may get the user profile information.

function GetUserProfileInfo() {
    var _usrInputID = "5";
    var ctx = new SP.ClientContext.get_current();
    var list = ctx.get_web().get_siteUserInfoList();
    var query = new SP.CamlQuery();
    query.set_viewXml('<View><Query><Where><Eq><FieldRef Name="ID" /><Value Type="Counter">'+_usrInputID+'</Value></Eq></Where></Query></View>');
    items = list.getItems(query);
    ctx.load(items);
    ctx.load(items, 'Include(ContentType)');
    ctx.executeQueryAsync(onSuccess, onFailure);
/* Success callback */
function onSuccess() {
    var listEnumerator = items.getEnumerator();
    while (listEnumerator.moveNext()) {
    var currentItem = listEnumerator.get_current();
    var contentType = currentItem.get_contentType();
    var contentTypeName = contentType.get_name();
    if(contentTypeName == 'Person')
        {
            alert("User Name : "+ currentItem.get_item('Title') + "\nEmail" + currentItem.get_item('EMail'));
        }
    else if(contentTypeName == 'SharePointGroup')
        {
            alert("Group Name : "+ currentItem.get_item('Title') + "\nGroup ID : " + currentItem.get_item('ID'));
        }
    }
}
/* Failure callback  */ 
function onFailure() {
alert('Error: ' + args.get_message() + '\n' + args.get_stackTrace());
}
}

See below coding to extract the sel id from url.

function Get_usrInputID()
{
    var cHrefURL = unescape(window.location.href);
    var res = '';
    if(cHrefURL.indexOf('IsDlg') > cHrefURL.indexOf('sel='))
    {
        res = cHrefURL.substring(cHrefURL.indexOf('sel=')+4,cHrefURL.indexOf('IsDlg'));
    }
    else
    {
        res = cHrefURL.substring(cHrefURL.indexOf('sel=')+4);
    }
    res = ReplaceAll(res,'&amp;','')
    res = ReplaceAll(res,'&','')
    var arrayOfStrings = res.split(',');
    return arrayOfStrings;
}

function ReplaceAll(str, find, replace) {
  return str.replace(new RegExp(find, 'g'), replace);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.