Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a users manager in AzureAD using Microsoft.Azure.ActiveDirectory.GraphClient

I'm using the Microsoft.Azure.ActiveDirectory.GraphClient (Version 2.1.0) to write an app for Azure AD user management. I'm able to set the Manager of a user but have no idea how to clear the field.

Unfortunately the sample project provided on GitHub do not contain this function either.

like image 773
stefboe Avatar asked Mar 02 '16 17:03

stefboe


People also ask

How do I remove an Azure administrator?

Azure portalSelect Azure Active Directory > Administrative units and then select the administrative unit you want to delete. Select Roles and administrators, and then open a role to view the role assignments. Remove all the role assignments with the administrative unit scope.

Can you disable a user in Azure AD?

You can use the Active Roles Web Interface to disable a user for logon to Azure. This allows you to disable a previously enabled user in Azure AD while retaining all the Azure settings that were configured for the user. The Azure AD user settings are retained for a disabled account.


1 Answers

I managed to clear the "manager" field using the code below. It is not using the Microsoft.Azure.ActiveDirectory.GraphClient library but gets the job done.

var token = <get your adal token here>
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Authorization = 
    new AuthenticationHeaderValue("Bearer", token);

var url = "https://graph.windows.net/<tenant domain>/users/<userid>/$links/manager?api-version=1.6"
var resp = httpClient.DeleteAsync(url).Result;
if (!resp.IsSuccessStatusCode)
{
    // log / throw exception etc.   
}
like image 120
stefboe Avatar answered Oct 11 '22 01:10

stefboe