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

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...