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 :
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

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    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

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans