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

Upload data from Excel in D365FO X++

 Action Menu Item: SAN_UploadExcelData Object type: Class Object: <Controller class name> Label: <> Class: Controller class clas...