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)

X++ set up folder permission

(0) ShareShare
ReportReport
Posted on by

Hi all,

I followed this http://community.dynamics.com/ax/b/technicaltutorialsformsdynamicsax2012/archive/2014/02/26/set-folder-file-read-write-permission-from-ax to do a test. 

But i have this problem. I can add the user to this folder, but this user cannot get any permission.

QQ_2A62FE56_20151023135241.jpg

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,805 Most Valuable Professional on at

    Doesn't your code throw an exception?

  • Community Member Profile Picture
    on at

    Hi Martin,

    No. No warning,no error.

  • Martin Dráb Profile Picture
    237,805 Most Valuable Professional on at

    No, I didn't mean whether you get something in infolog. That's a different topic.

    AX won't show any message for .NET exceptions, it just stops the execution. You can verify it in debugger, you can add some trace message at the end of your program (to see that nothing crashed), or you have to actively catch the exception (and then you can add something to infolog by yourself, e.g. by calling throw error(AifUtil::getClrErrorMessage());

  • Pir_Rana Profile Picture
    836 on at

    Hi,

    Put exception handler and use the line which Martin gave in last reply.

    You will get error on  " DirectorySec.AddAccessRule(FilesysaccessRule)".

  • Community Member Profile Picture
    on at

    Hi,

    Yes, i got the error.

    Could you give me some advice?

  • Martin Dráb Profile Picture
    237,805 Most Valuable Professional on at

    It would help if you told us what error you got (message, exception type etc.).

  • Community Member Profile Picture
    on at

    No more specific error. So could you give me another solution? I'm not sure this post is right.QQ_2A62FE56_20151023171251.jpg

  • Martin Dráb Profile Picture
    237,805 Most Valuable Professional on at

    No, it's impossible that the exception had no type. Also having no message would be very unusual.

    The picture merely shows that your code failed to extract the message.

    Use the debugger to find more. You can't fix it unless you know what failed.

  • Martin Dráb Profile Picture
    237,805 Most Valuable Professional on at

    I can try your code if you share it as text; I'm not going to retype it from the picture.

  • Community Member Profile Picture
    on at

    static void FolderPermission(Args _args)

    {

       System.Security.AccessControl.DirectorySecurity     directorySec;

       System.IO.DirectoryInfo                             dirInformaiton;

       System.Security.AccessControl.FileSystemAccessRule  filesysaccessRule;

       System.Security.AccessControl.FileSystemRights      fileSysRights;

       System.Security.AccessControl.AccessControlType     accessControlType;

       UserInfo                                            userInfo;

       System.Security.AccessControl.InheritanceFlags      inheritFlags;

       System.Security.AccessControl.PropagationFlags      propFlags;

       ;

       dirInformaiton    = new System.IO.DirectoryInfo("C:\\temp\\test1");  //folder path

       directorySec      = dirInformaiton.GetAccessControl();

       fileSysRights     = System.Security.AccessControl.FileSystemRights::Write;

       inheritFlags      = System.Security.AccessControl.InheritanceFlags::ObjectInherit;

       propFlags         = System.Security.AccessControl.PropagationFlags::NoPropagateInherit;

       accessControlType = System.Security.AccessControl.AccessControlType::Allow;

       filesysaccessRule = new System.Security.AccessControl.FileSystemAccessRule('ess-sym', fileSysRights, inheritFlags, propFlags, accessControlType); //please use the domain account

       directorySec.AddAccessRule(filesysaccessRule);

       dirInformaiton.SetAccessControl(directorySec);

    }

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