Pages

Thursday, October 28, 2010

Using X++ to figure out which user the AOS runs under

This code will give you the AOS accounts domain and username:

public static void main(Args args)
{
    InteropPermission   permission;
    str                 userName;
    str                 userDomain;
    ;
    permission = new InteropPermission(InteropKind::ClrInterop);
    permission.assert();
    userDomain  = System.Environment::get_UserDomainName();
    userName    = System.Environment::get_UserName();
    info(strFmt(@"%1\%2", userDomain, userName));
}

The code must be executed from the server tier.