Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Disabling and enabling XDS security in code not working as expected

(0) ShareShare
ReportReport
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
    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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics AX (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 100 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 48

#3
shanawaz davood basha Profile Picture

shanawaz davood basha 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans