Sunday 23 October 2011

Change File Ownership through X++ in Dynamics AX

Hi all , while working with AIF using file system adapter, it is very painful to update every time the owner of XML file , otherwise AX will not read the file and will throw the error , I have used icacls utility to update the ownership of file . I have modifed the class AIFFileSystemreceiveadapter , you can find it on skydrvie. https://skydrive.live.com/redir.aspx?cid=32417e20be1cdd11&resid=32417E20BE1CDD11!114

\
The changed code is as below  :


 select * from userInfo where userInfo.Id == curuserid();
 domain = System.Environment::get_UserDomainName();
 command = "/c" + " icacls " + filePath  + " /setowner "  +  domain + "\\" + userInfo.networkAlias;
 WinAPI::shellExecute("cmd.exe", command);


Thanks,

No comments:

Post a Comment