Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

AX2012 XDS : Disable security policy

Posted on by Microsoft Employee

Recently we had the requirement to create a new security policy to restrict access on custTable for a salesman role.

XDS was very helpfull and easy to implement this requirement.

 

Now we faced the following problem:

Suppose the following scenario:

We have a salesman having access to the following customers:

  • Customer A
  • Customer B 
  • Customer C (No access enforced by XDS)

Customer B has a relation to customer C. During sales order creation for customer B some values of customer C needs to be read.

 

How can this be achieved?

Is there a way in temporary disabling the XDS policy for the given scenario?

I've seen that there exists xRecord.setXDSContext http://msdn.microsoft.com/en-us/library/xrecord.setxdscontext.aspx can this may be a help in implementing this scenario?

Any help will be appreciated.

*This post is locked for comments

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 Season 2 on at
    RE: AX2012 XDS : Disable security policy


    Hi Thomas,

    You can use the XDSServices class in code:

        XDSServices                      xXDS = new XDSServices();
         
       
        xXDS.setXDSState(0);

    To bypass the secuirty in x++ code, you can also create or use a view where the CustTable and the needed fields are defined. The View itself has its own name and XDS security context.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: AX2012 XDS : Disable security policy

    I think you need to change the XDS query so that you can have customer C also get included

    Please review and let us know your findings

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: AX2012 XDS : Disable security policy

    I think you can do this by doing xRecord.setXDSContext(...) before selecting the record.

    Look at \Tables\DirPersonName\Methods\nameLikeCount for an example (they restrict here).

    Ctrl+F on the AOT for some other examples.

  • Janne Kuula Profile Picture
    Janne Kuula 5 on at
    Re: AX2012 XDS : Disable security policy

    The only way that I've found to bypass XDS in code is to run the code as a user for whom the policy (or XDS altogether) is not enabled, like on this example:

    public static void restrictedMethod(str _parameter)
    {
        RunAsPermission     perm = new RunAsPermission("admin");
        str                 returnValue;

        perm.assert();

        [returnValue] = runAs("admin", classnum(XDSBypassClass), "unrestrictedMethod", [_parameter]);

        CodeAccessPermission::revertAssert();
    }

    server public static container unrestrictedMethod(container _params)
    {
        str param;
        str ret;

        [param] = _params;

        //Set return value(s) or directly modify data with unrestricted table access here

        return [ret];
    }

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans