Can't add member to a group in Azure Active Directory through Graph API -


i have following code inside web api controller, of debugging purposes:

public void register([frombody]accountinfo accountinfo)     {         user user = new user();         user.accountenabled = true;         user.displayname = accountinfo.username;         user.userprincipalname = string.format(cultureinfo.invariantculture, "{0}@{1}", user.displayname, configurationmanager.appsettings["tenantdomainname"]);         user.mailnickname = accountinfo.username;         user.passwordprofile.password = accountinfo.password;         user.passwordprofile.forcechangepasswordnextlogin = false;         directoryservice.addtousers(user);         directoryservice.savechanges();          group securitygroup = directoryservice.groups.where(u => u.displayname.equals(accountinfo.securitygroup)).first();         user addeduser = directoryservice.users.where(u => u.objectid.equals(user.objectid)).first();         directoryservice.loadproperty(addeduser, "memberof");         directoryservice.loadproperty(securitygroup, "members");          directoryservice.addlink(securitygroup, "members", addeduser);         //securitygroup.members.add(addeduser);         var users = securitygroup.members.tolist();         var links = directoryservice.links;         //directoryservice.updateobject(securitygroup);         directoryservice.savechanges();     } 

the above code adds user in windows azure active directory , attempts add user group. user gets added waad without glitches, code fails on last line

"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">authorization_requestdeniedinsufficient privileges complete operation."

error message. doesn't let me add user group. since service principal has enough privileges add user aad, why wouldn't able add user existing group?

you need give proper access in azure portal , configure in project web application and/or web api. changes made in portal (before had lot of things using powershell).

we made article explaining more or less how configure everything:

http://www.clouddevx.com/en-us/blog/artmid/836/articleid/2

edit:

just give more explanation think have set service informations client id , password obtained in azure portal:

var tenantname = "emyode.com";

string clientid = "clientid obtained in azure portal";

string password = "security key obtained in azure portal";

var token = directorydataserviceauthorizationhelper.getauthorizationtoken(tenantname, clientid, password);

var graphservice = new directorydataservice(tenantname, token);


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -