Enter the key words to find the related topics

Showing posts with label AX application user login authentication. Show all posts
Showing posts with label AX application user login authentication. Show all posts

AX application user login authentication

Requirement: AX application need to open with user credential. If credential is given wrong then application should close.

Solution: Modified startupPost method in  Info class as shown below.



    Dialog                dialog;
    Dialogfield         dName,dPassword;
    Userinfo              user;
    boolean                ret;
    SysClientSessions   sysClientSessions;
    AxaptaUserManager   axUserManager;

    dialog      = new dialog("User login");
    dialog.formBuildDesign().height(170);
    dialog.formBuildDesign().width(400);

    dName       = dialog.addField(ExtendedTypestr(userid),"User name");
    dPassword   = dialog.addField(ExtendedTypestr(Password),"Password");
    dName.enabled(false);

    dName.value(curuserid());

     select firstOnly id from user
            where user.id == dName.value();

    if (user.id != "Admin")
    {
        dPassword.passwordStyle(true);
        dialog.parmIsModal(true);


        axUserManager = new AxaptaUserManager();
        if (dialog.run())
        {
            if (!axUserManager.validatePassword(user.networkAlias , user.NetworkDomain, dPassword.value()))
            {
                infolog.shutDown(true);
            }
            else
            {
                Box::info("Access granted.","AX Group","ERP");
                ret = true;
            }
        }

        if (ret == false && user.RecId)
        {
            infolog.shutDown(true);
        }
    }