ActiveDirectoryUsersFromKanhaServer in ax 2012
static void ActiveDirectoryUsersFromKanhaServer(Args _args)
{
str computer = new xSession().clientComputerName();
xAxaptaUserManager mgr = new xAxaptaUserManager();
xAxaptaUserDetails usr;
container doms;
int d, u;
str dom, login, name, sid, email;
;
// iterate AD domains
doms = mgr.enumerateDomains(computer);
for (d = 1; d <= conlen(doms); d++)
{
dom = conpeek(doms, d);
setprefix(dom);
// iterate AD domain users
usr = mgr.enumerateDomainUsers(dom);
for (u = 0; u < usr.getUserCount(); u++)
{
if (usr.isUserEnabled(u) && !usr.isUserExternal(u))
{
// get information from AD
login = usr.getUserLogin(u);
name = usr.getUserName(u);
sid = usr.getUserSid(u);
email = usr.getUserMail(u);
// stuff happens here, you can compare AD data with AX User info
info(strfmt("%1 - %2 - %3 - %4 - %5", dom, login, name, email, sid));
}
}
}
}
No comments:
Post a Comment