Some examples:
How to get the SID from AD for a domain user:
static void GetSID(Args _args)
{
xAxaptaUserManager xUsrMgr = new xAxaptaUserManager();
;
info(xUsrMgr.getUserSid('youruserid','youraddomain'));
}Note: Remember you can user the field networkalias from table UserInfo to do a conversion from Ax user id to the domain user id.
You can use this class for various purposes. Also for checking a password.
How to validate the system password in AD from within Ax
static void CheckPassword(Args _args)
{
xAxaptaUserManager xUsrMgr = new xAxaptaUserManager();
;
if(xUsrMgr.validatePassword('youruserid','youraddomain','yourpassword'))
info('Password correct');
else
error('Password incorrect');
}We could get some more information from the AD regarding the user by using class xAxaptaUserDetails.
How to get the user name from AD for a user
static void GetADUserName(Args _args)
{
xAxaptaUserManager xUsrMgr = new xAxaptaUserManager();
xAxaptaUserDetails xUsrDet;
;
xUsrDet = xUsrMgr.getDomainUser('youraddomain','youruserid');
if(xUsrDet)
info(xUsrDet.getUserName(0));
}How to get the email address from AD for a user
static void GetADEmailAddress(Args _args)
{
xAxaptaUserManager xUsrMgr = new xAxaptaUserManager();
xAxaptaUserDetails xUsrDet;
;
xUsrDet = xUsrMgr.getDomainUser('youraddomain','youruserid');
if(xUsrDet)
info(xUsrDet.getUserMail(0));
}So the AD holds no secrets for one that knows Ax...
Works fine but what if I would like to read other LDAP fields? Is there a possiblilty to get AD-User details by SID?
ReplyDelete