Friday, 21 February 2014

How to get SID of ax user system in ax 2012

static void GetUserSID(Args _args)
{
str windowsUser = 'anshuljain.in\\anshul.jain'; // DomainName\\userId
#Aif
#File
networkALias alias;
networkDomain domain;

int pos, len;
sid userSid;
Microsoft.Dynamics.IntegrationFramework.Util util;
;
//Split the windowsUser into domain and alias
len = strlen(windowsUser);
pos = strfind(windowsUser, #FilePathDelimiter, 1,len);
domain = substr(windowsUser, 1, pos-1);
alias = substr(windowsUser, pos+1, len - pos);

new InteropPermission(InteropKind::ClrInterop).assert();
// BP Deviation Documented
util = new Microsoft.Dynamics.IntegrationFramework.Util();

//Get the Windows SID for this user
// BP Deviation Documented
userSid = util.GetUserSid(domain, alias);
CodeAccessPermission::revertAssert();

info(userSid);
}

No comments:

Post a Comment