Pages

Tuesday, March 27, 2012

Job to export all AX 2009 security groups to files

I have been changing security a bunch lately and it's nice to have a backup of your previous settings if you make a mistake.  Here is a quick job I wrote to export your existing security settings to a folder.



static void ExportSecurityGroups(Args _args)
{
    SysSecurityUserGroup    sysSecurity = SysSecurityUserGroup::construct();
    UserGroupInfo           userGroupInfo;
    DomainInfo              domainInfo;

    #file
    Dialog                dialog  = new Dialog("@SYS14863");
    DialogField           dialogFileName;
    DialogField           dialogDomain;
    Object                formdialog;
    ;

    dialogFileName = dialog.addField(typeid(FilePath),"@SYS16423");
    dialogDomain    = dialog.addField(typeid(DomainId), "@SYS89852");
    dialog.doInit();
    formdialog = dialog.formRun();
    formdialog.filenameLookupTitle("@SYS53669");

    if (dialog.run() && WinAPI::pathExists(dialogFileName.value())  &&
        (dialogDomain.value() == ''     ||
         (select firstonly domainInfo where domainInfo.Id == dialogDomain.value()).recId != 0))
    {
        if (dialogDomain.value() == '')
            dialogDomain.value('Admin');
        
        while select userGroupInfo
        {
            sysSecurity.parmUserGroupId(userGroupInfo.id);
            sysSecurity.parmDomainId(dialogDomain.value());
            sysSecurity.load();
            sysSecurity.export(dialogFileName.value() + @'\' + dialogDomain.value() + '_' + userGroupInfo.id + '.asg');
        }
    }
    else
        warning("No action taken...");

    info("Done");
}

9 comments:

  1. Nice tool, but there is something missing: the Domain. When I tried running it, all of the groups contained empty information. Before the dialog setup (the first line of runnable code), I added:
    sysSecurity.parmDomainId([DomainId]);

    Now everything exports properly. For implementations with multiple domains, you may want to go a little bit further and add a dropdown box to select which domain to export from.

    ReplyDelete
    Replies
    1. Great comment. The environment I was working in didn't use Domains so I spaced them. I've updated the job to work with domains.

      Delete
  2. I am thankful to you for sharing this plethora of useful information. I found this resource utmost beneficial for me. Thanks a lot for hard work. Melbourne Integriti

    ReplyDelete
  3. Going to graduate school was a positive decision for me. I enjoyed the coursework, the presentations, the fellow students, and the professors. And since my company reimbursed 100% of the tuition, the only cost that I had to pay on my own was for books and supplies. Otherwise, I received a free master’s degree. All that I had to invest was my time. security guards

    ReplyDelete
  4. I got this blog site through my friends and when Home Security Companies I searched this really there were informative articles at the place.

    ReplyDelete
  5. I haven't yet met an unsuccessful job seeker who was in some way lacking in self-confidence. It is one of the reasons that I decided to in part cross the divide and become a CV Writer, because universally in most job searches the CV is a common point. Job consultancy

    ReplyDelete
  6. Most job boards do not allow for listing of emails, URL's, use of copyrighted material, defamatory remarks, false, inaccurate or misleading information, illegal or unethical content. Job postings that encourage job seekers to email for more details, are usually prohibited.How to Make cover letter

    ReplyDelete
  7. With a chronological resume, ashamed of being unemployed it requires someone to look at each job and try to ascertain or guess what skills a person has and in a competitive job market that type of extensive review may not be conducted.

    ReplyDelete
  8. Well, it’s a nice one, I have been looking for. Thanks for sharing such informative stuff.
    Continued

    ReplyDelete