AOS service account

How to get AOS service account user name through X++?

Hi Martin Dráb

Can please help me solve this problem.?

Sorry, I don’t feel that the question can be answered unequivocally. The answer would depend on your actual requirements and limitations. I also wonder why you need that.

Please give us more information if you want to get your question answered. Just copying the same question to more and more forums won’t help.

Actually I want to check service Log On Account have rights to the application files over the network.

You don’t need the name of the account. Just check whether the current user has permissions and run the code from server, therefore current user == AOS service.

Thank you so much Martin I will try with your solution.

Hi Martin,

I was trying with your solution, But the problem is I am getting error when I am running my code in batch.

Code :

cnlEUCommaIo = new commaIo(cnlEUFileName, #io_write);



following code

Hi Martin,

I was trying your solution, But when I am running following code in batch I am getting error else I am not getting any error.


cnlEUPermissionSet = new Set(Types::Class);

PermissionSet.add(new FileIoPermission(FileName,#io_write));

PermissionSet.add(new InteropPermission(InteropKind::ClrInterop));


CommaIo = new commaIo(FileName, #io_write);



Throw error(“User doesn’t have enough permission to write file into this path %1”);


user and file path is same in both the cases.

You forgot to tell us what error it is, nevertheless my crystal ball says that either the path isn’t accessible from AOS or the service account really doesn’t have permissions.

Hi martin,

I have two following questions,

How can I can find path is accessible from AOS or not.?

Is it possible to display service user account name in my error message.?

For example, you can log on to the AOS server and try to open the path in Windows Explorer. Nevertheless if you use local path of the client machine, it’s immediately clear hat it can’t work from other machines.

You surely could get the service account name, but I thought we already agreed that it’s not needed, so I’m not going to spend my time with it.

Yes martin, Thank so much for help now I am using curuserid() method to display current user id. Problem solved.

I’m glad that your problem is solved, although curUserId() has nothing to do with the service account. It seems that you asked a wrong question.

Please mark this thread as answered.

Actually I was not clear about requirement.