I am trying to get current user group name when the member is added via Active Directory in SharePoint 2013 using Rest/jQuery. Any help is appreciated.

first you have to use "currentUser" api to get current user id,then try use "GetUserById" function to list all groups.

function getCurrentUser()   
{  
getUserWebPermissionREST();  
$.ajax({  
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/CurrentUser",  
method: "GET",  
headers: { "Accept": "application/json; odata=verbose" },  
success: function (data)  
{  
getCurrentUserGroupColl(data.d.Id);  
},  
error: function (data)   
{  
failure(data);  
}  
});  
}  
function getCurrentUserGroupColl(UserID)   
{  
$.ajax  
({  
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetUserById(" + UserID + ")/Groups",  
method: "GET",  
headers: { "Accept": "application/json; odata=verbose" },  
success: function (data) {  
/* get all group's title of current user. */  
var results = data.d.results; var InnrHtmlgrp = "  
    <ul>";  
for (var i = 0; i < results.length; i++)   
{  
InnrHtmlgrp += "  
        <li>" + results[i].Title + "</li>";  
}  
$("#Group").append(InnrHtmlgrp + "  
    </ul>");  
}  
});  
}  

https://social.technet.microsoft.com/wiki/contents/articles/36658.using-sharepoint-2013-get-current-user-group-collection-through-rest-api.aspx

var grp = new SPAPI_UserGroup("https://Site Url"); // pass site url

sLoginUserName1 = "test@test.com";   // email id of the user which is rendering in site

var ug = grp.getGroupCollectionFromUser(sLoginUserName1);

var rows = ug.responseXML.getElementsByTagName('Group');

for (var i=0; i< rows.length; i++){

alert(rows[i].getAttribute('Name'));

}

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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