Posts

Showing posts from January, 2016

Deleting Azure Active Directory Users in C#

Image
Using the Azure Active Directory with the official client Libraries is straighforward. Just Install the required libraries in your C# Project
PM> Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory for authenticating yourself against the AD - and
PM> Install-Package Microsoft.Azure.ActiveDirectory.GraphClient for accessing the directoryCreate your application in the directoryGenerate a ClientSecret for the ApplicationGive permission to manager the AD to the ApplicationPut it all together See: http://justazure.com/azure-active-directory-part-5-graph-api/ for further assistance.
But When it comes to deletion of objects (Users, Groups, etc.) it will become less easy, because the application you created has not enough permissions to delete objects. You might see the error

"Insufficient privileges to complete the operation."
This is caused by the setup of the application in the AD itself and the missing membership to the "Company Administrator"-Role.

See…