Hi all,

I created a job that exports all the security-settings which are in the system 
to files. The filenames are build like this:
DomainId#UserGroupId.asg

I also created a job to import these files (from a certain directory). It's 
great to test your security-settings in a test-system and after that import 
them in your production environment.

Serge

static void ExportAllUserGroupsToFiles(Args _args)
{
    // ????????? ??? ????? ????? ????????????? ? ????????? ?????? ? ????????? 
????????
    SysSecurityUserGroup    sysSecurity;
    UserGroupInfo           userGroupInfo;
    userGroupId             userGroupId , tmpUserGroupId;
    domainId                domainId    , tmpDomainId;
    domainInfo              domainInfo;

    FilePath                filepath;
    FileNameSave            fileName, fileNameExport;
    BinaryIo                file;
    Filename                path, onlyName, ext;
    int                     hwnd;
    ;
    filePath = winApi::browseForPath(hwnd);

    if (filePath)
    {
        sysSecurity = SysSecurityUserGroup::construct();

        while select domainInfo
        {
            domainId = domainInfo.id;

            while select userGroupInfo
            {
                userGroupId = userGroupInfo.id;
                if (userGroupId != 'Admin')
                {
                    fileNameExport = domainId + '#' + userGroupId;
                    fileName = filePath + '\\' + fileNameExport;

                    tmpUserGroupId = sysSecurity.parmUserGroupId();
                    tmpDomainId    = sysSecurity.parmDomainId();

                    sysSecurity.save();
                    sysSecurity.parmDomainId( domainId );
                    sysSecurity.parmUserGroupId( userGroupId );
                    sysSecurity.load();
                    sysSecurity.export( fileName );
                }
            }
        }
    }
}

static void ImportUserGroupRightsFromFolder(Args _args)
{
    integer             hdl, pos;
    FileName            fileName;
    DomainId            domainId;
    UserGroupId         userGroupId;
    FilePath            filePath = "C:\\temp\\security\\";
    int                 hwnd;
    #File
    ;
    filePath = winApi::browseForPath(hwnd);

    if (filePath)
    {
        filePath += '\\';
        [hdl, fileName] = WinAPI::findFirstFile(filePath + #AllFilesName + 
#AllFilesExt);
        setPrefix('Start');
        while (fileName)
        {
            pos = StrFind(filename,"#",1,strlen(fileName));
            if (pos > 0)
            {
                setprefix(filePath + filename);
                domainId = substr(fileName,1,pos-1);
                userGroupId = 
strreplace(substr(fileName,pos+1,strlen(fileName)),'.asg','');
                info(strfmt('Domain: %1, Group: %2',domainId,userGroupId));
                //info(userGroupId);
                
sysSecurityUserGroup::importRights(userGroupId,domainId,filePath + fileName);
            }
            fileName = WinAPI::findNextFile(hdl);
        }
        WinAPI::findClose(hdl);
    }
}

-----Oorspronkelijk bericht-----
Van: [email protected]
[mailto:[EMAIL PROTECTED] Steeve Gilbert
Verzonden: vrijdag 16 februari 2007 14:43
Aan: [email protected]
Onderwerp: [development-axapta] Re: Exporting Security Settigns for User
Groups


Hi,

You can export a user group and it's setting.  Go to the user group 
form, select the group, click "Permissions" and on the right you'll 
see "Export".  Try that.  As for where is stored this data, I don't 
know.

Steeve...

--- In [email protected], "cbharda" <[EMAIL PROTECTED]> 
wrote:
>
> Gidday Everyone,
> 
> Just wondering if it was possible to export a user group and all of
> it's security settings.
> 
> The User Groups are stored in the table UserGroupInfo, but where is
> the actual settings for these groups stored?
> 
> Thanks for your time,
> 
> Cy
>




 
Yahoo! Groups Links



Reply via email to