Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Disabling and enabling XDS security in code not working as expected

Posted on by 50

We're using Dynamics AX 2012 R2 CU7 and using XDS policies with some of our security roles.


The problem is that one role needs to confirm a sales order that was entered by another role.  Both roles have XDS security policies on them. During the confirmation, XDS security kicks in and causes issues, so the game plan was to use the XDSServices class to turn off XDS security during the confirmation process.

This is effectively what is in our codebase to do the work in the FormLetterService class.

[SysEntryPointAttribute]
FormletterOutputContract postSalesOrderConfirmation(SalesFormLetterConfirmContract _contract)
{
    XDSServices xdsServices;
    formLetterContract = _contract;

    xdsServices = new XDSServices();

    xdsServices.setXDSState(0);

    this.run();

    xdsServices.setXDSState(1);

    return outputContract;
}

Here's where it gets fun.  If CIL is enabled, this does not work.  I've captured the process via the Tracing Cockpit and seen the queries where XDS is appending to the sql queries.

Here's where it gets really fun.  If I run without CIL, this works great.  The Sales Order confirms with no issues.  It looks like the XDS security gets disabled as expected and re-enabled at the end.  Because of this, I'm very confused.  I'm not sure if it's cause maybe the code is jumping tiers or getting out of scope for some reason, but it's pretty annoying. 

Anyone have any ideas or suggestions? I did see a comment around using the RunAs to the block of code as a different user, but that would probably be a pile more work in the end.  But, if it's a pile of work that'll fix my issue, I'm willing to head that route.

*This post is locked for comments

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,149 on at
    RE: Disabling and enabling XDS security in code not working as expected

    AX in some cases opens a new worker thread or UserConnection, for which the XDS state probably does not apply.

    Disabling XDS works pretty well for our custom AIF services where it only exists in one worker/connection session, so maybe your issue is the multiple workers indeed. The solution in that case would be to wrap the whole call in RunAs with a user account who does have the correct access rights without XDS indeed.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans