Tuesday, February 6, 2018

Disable non AD user in AX

   xAxaptaUserManager axUsrMgr;
    xAxaptaUserDetails axUsrDet;
    UserInfo userInfo;
    UserInfo userInfoUpdate;
    str userID;
    str domainName;
    str userSid;
    userAccountType accountType; 
    ;
    axUsrMgr = new xAxaptaUserManager();
    while select userInfo where userInfo.enable == true
    {
        userID = userInfo.networkAlias;
        domainName = userInfo.networkDomain;
        accountType = userInfo.accountType;
        try
        {
            axUsrDet = axUsrMgr.getSIDFromName(userID, domainName, accountType);
        }
        catch(Exception::Error)
        {
           ttsBegin;
            select forUpdate userInfoUpdate
                where userInfoUpdate.id == userInfo.id; 
            userInfoUpdate.enable = false;
            userInfoUpdate.doUpdate();
            ttsCommit; 
        }
    }

No comments:

Post a Comment

Convert Call stack to readable format in D365FO X++

//Input --container _xppCallStack = xSession::xppCallStack();  Public static str POL_formatXppCallStack(container _xppCallStack, int _skipFr...