web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Removing or disabling SecurityUserRoles for certain user via API

(0) ShareShare
ReportReport
Posted on by 30

Hi All,

I'm trying to remove security user role using API, but no luck yet.

I can create a mapping between user and security role using API:

/data/SecurityUserRoles

POST request looks like:

{
            "UserId""UserIDVal",
            "SecurityRoleIdentifier""11111111-1111-1111-1111-2EA6DC8E6711",
            "AssignmentStatus""Enabled",
            "AssignmentMode""Manual",
            "SecurityRoleName""Some name"
}
It works like charm. However, it does not give ID pf this assignment, so I could find it and modify or remove.
I need to remove this role now, but if I go and use filter to get this role like:
/data/SecurityUserRoles?$filter=UserId eq 'UserIDVal' and SecurityRoleIdentifier eq '11111111-1111-1111-1111-2EA6DC8E6711'
it finds just one assignment - the one like I have created. But if I do PATCH (or DELETE) instead of GET with this filter - I see error message like:
"More than one resource was found when selecting for update."
I can understand this message, because for GET request using filter like above Odata.context is '/data/$metadata#SecurityUserRoles' and even though there is a single result - it is returned like array. That is why API is saying that there are multiple results.
Is there any way to disable or delete user to security role mapping using REST API?
Thanks in advance
I have the same question (0)
  • nmaenpaa Profile Picture
    101,160 Moderator on at

    What if you try to POST / insert a new entry with same contents than your original one, but AssignmentStatus Disabled?

  • c4b14ca1-82ae-4ba1-81d9-375da19bad52 Profile Picture
    30 on at

    I tried that as well, but, unfortunately it does not work. It generates error message in this case:

    "Write failed for table row of type 'SystemSecurityUserRoleEntity'. Infolog: Info: Cannot create a record in Security user role (SecurityUserRole).\nThe record already exists.."

    So it looks like every POST request is for adding record, while PATCH or DELETE should work. However, trying to run them are not successful - like I tried to describe in my 1-st post (

  • Verified answer
    c4b14ca1-82ae-4ba1-81d9-375da19bad52 Profile Picture
    30 on at

    So I finally found a solution that is described here: stackoverflow.com/.../odata-selecting-single-entity-using-filter

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans