c# - Try to adding AppRoleAssignment -
i trying add approleassignment using code:
approleassignment objapproleassignment = new approleassignment(); objapproleassignment.id = guid.parse("00000000-0000-0000-0000-000000000000"); objapproleassignment.resourceid = guid.parse("serviceprincipalid"); objapproleassignment.principaltype = "user"; objapproleassignment.principalid = guid.parse(user.objectid); user.approleassignments.add(objapproleassignment); await user.updateasync();
i don't have roles specifying default 00000000-0000-0000-0000-000000000000
role
but error:
{"odata.error":{"code":"request_badrequest","message":{"lang":"en","value":"one or more properties invalid."},"values":null}}
the way doing correct. there seems 2 bugs in place make seem change isn't being saved.
- the first time run (the app role assignment doesn't exist), though request succeeds , indeed creates app role assignment, sdk error out because app role assignment in response has null id value, causes throw following exception:
a null value found property named 'id', has expected type 'edm.guid[nullable=false]'. expected type 'edm.guid[nullable=false]' not allow null values.
- if retry (once app role assignment created), you'll error you've shared quite misleading since problem isn't you've got bad values rather you're trying create approleassigment resource + principal has one. can confirm case querying (directly or via https://graphexplorer.cloudapp.net) following:
https://graph.windows.net/[yourtenant]/serviceprincipals/[resourceid]/approleassignedto
or
https://graph.windows.net/[yourtenant]/users/[principalid]/approleassignments
we're looking correcting issue, in interim options either swallow exception in #1 or not use sdk , manually craft post request approleassignments.
Comments
Post a Comment