Home General Discussion

Custom tasks for AD groups?

JD_KeithJD_Keith Customer IT Monkey ✭
I'm wondering how I can scope custom tasks to only be available for specific AD groups.  Thanks for the help!


  • Morten_MeislerMorten_Meisler Premier Partner Advanced IT Monkey ✭✭✭
    I made this script that uses the API to retrieve the logged in users group membership. It's very quickly made, but hope you get the idea :)

    var GroupName = "DOMAIN\\MyADGroup"
    		url: 'http://' + window.location.host + '/api/V3/User/GetUsersGroups',
    		async: true, //this is the default but showing that it can be turned off
    		data: {
    			id: session.user.Id		
    		type: "GET", //this particular portal API call is a GET type
    		statusCode: {
    			200: function (data) {
    			    //Call function to hide or show task
    		error: function (jqXHR, textStatus, errorThrown) {
    			//debug console.log(errorThrown);
    			//debug console.log(textStatus);
    function hideShowTask (data)
        var IsMemberOfGroup = false;
        //for each returned group that user is member of..
        $(data).each(function () {
            //Check if the returned group matches our groupname
            if (this.Name === GroupName)
                IsMemberOfGroup = true;
        if (IsMemberOfGroup)
            //User is member - task will be shown
            console.log("User: " + session.user.Name + " is member of group: " + GroupName)
            //User is not member of group - Hide task
            console.log("User: " + session.user.Name + " is NOT member of group: " + GroupName)
            $( ".taskmenu li:contains('Resolve Incident')" ).hide() 

Sign In or Register to comment.