Write a file to a folder through X++ when the current user is missing write permission

Let’s say a user “Guest” doesn’t have a permission to write in folder “Backup”. Is it possible to write code in AX so that a file is copied/moved to “Backup” while “Guest” is the current user? If so, how can I achieve that?

For example, maybe it’s possible to use another (e.g. service account) user account which has a permission to write in “Backup” folder.

you can use .net frameowrk inside ax

System.Object ftpo;
System.Net.FtpWebRequest request;
System.IO.StreamReader reader;
System.Net.NetworkCredential credential;
System.Net.FtpWebResponse response;
System.String text;
;
ftpo = System.Net.WebRequest::Create(“ftp://ftpserver.com/dir/myfile.txt”);
request = ftpo;
credential = new System.Net.NetworkCredential(“user”,“password”);
request.set_Credentials(credential);

response = request.GetResponse();
reader = new System.IO.StreamReader(response.GetResponseStream());
text = reader.ReadToEnd();
info(text);

The best option would be using a batch scheduled by an administrator.

You can also use runAs() function in AX, but you would have to be careful not to compromise security of your system.