To Create login credentials for ax2012 application using X++

        to create login credentials for our ax application we have wright code in the classes, which are executed while openinmg the application.
 
So we will wright our code in Application class and also Info Class.
And put the following code in StartupPost method.
Now im using the Info Class. 

Path:- \Classes\Info\startupPost

put the following code in startuppost Method

    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);
        }
 }

No comments:

Post a Comment