Sunday, 10 January 2016

Job for creation of user by x++

this job will create a user in ax 2012

static void Usercreation(Args _args)
{
    UserInfoHelp            userInfoHelp;
    UserAdAddManager        userManager;
    int                     i;
    UserInfo                userInfo;

    Microsoft.Dynamics.IntegrationFramework.Util    util;


    userInfoHelp        = new UserInfoHelp();
    util                = new Microsoft.Dynamics.IntegrationFramework.Util();

    userInfo.company    = "USMF";
    userInfo.enable     = NoYes::Yes;
    userInfo.name       = "Rohit";
    userManager         = UserAdAddManager::construct();

    userInfo.accountType    = UserAccountType::ADUser;
    userInfo.language       = LanguageTable::defaultLanguage();
    userInfo.networkAlias   = "naresh.k";
    userInfo.networkDomain  = "ANT.COM";
    userInfo.id             = userInfo.networkAlias;
    while (userManager.validateInitialUserId(userInfo.id) == false)
    {
        i ++;
        userInfo.id         = userManager.generateInitialUserId(userInfo.id, i);
    }
    userInfo.sid            = util.GetUserSid(userInfo.networkDomain, userInfo.networkAlias);
    userInfo.insert();
    info("done");
}

No comments:

Post a Comment

intercompany PO multiple product receipt by x++

public void processStampICPO(PackingSlipId _deliveryNote,                             Transdate _deliverydate,                             ...