web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

AX 2009 Security: Copy From One User to Other (Thru X++ / Code )?

(0) ShareShare
ReportReport
Posted on by 70

Hello,

I understand AX 2009 Security is completely different than newer version of AX. We have been having challenge with User Permissions.

  • We have 2 Users: User A (Old employee) & User B (Newly joined)
  • We have kept Security User Group groups of User B same as User A
  • However, User B is not able to do certain tasks as User A.

I am wondering if is there is any way to copy all Security Permissions from 'User A' to 'User B'? Like thru Code or something?

Any suggestion will be appreciated much.

Thanks,

Ronak

*This post is locked for comments

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    299,349 Super User 2025 Season 2 on at
    RE: AX 2009 Security: Copy From One User to Other (Thru X++ / Code )?

    Hi Ronak,

    If you assign this new user to all the user groups which were assigned to the old user, this person should have the same permissions. Can you elaborate on what is different after you have checked all group assignments? There might be some module settings which could play a role here.

  • Community Member Profile Picture
    on at
    RE: AX 2009 Security: Copy From One User to Other (Thru X++ / Code )?

    static void AXEcopyUserGroup(Args _args)
    {
        usergrouplist usergrouplist,ins;
        userid src,dest;
        dialogfield srcdf,destdf;
        dialog dialog;
        ;
        dialog = new dialog("copying user's user groups");
        srcdf = dialog.addField(typeid(userid),"Source");
        destdf = dialog.addField(typeid(userid),"Destination");
        

        
        if(dialog.run())
        {
            src = srcdf.value();
            dest = destdf.value();
            if(src!="" && dest !="")
            {
                ttsbegin;
                while select * from usergrouplist
                where usergrouplist.userId == dest
                {
                    info(strfmt("Before update: '%1'-'%2'",usergrouplist.userid,usergrouplist.groupId));
                }
                
                info("Deleting user groups from destination user");
                delete_from usergrouplist
                    where  usergrouplist.userId == dest;
                    
                    
                info("Copying user groups to destination user");
                while select * from usergrouplist
                where usergrouplist.userId == src
                {
                    info(strfmt("source user: '%1'-'%2'",usergrouplist.userid,usergrouplist.groupId));
                    ins.clear();
                    ins.data(usergrouplist);
                    ins.UserId = dest;
                    ins.insert();
                }
                ttscommit;
                info("User groups has been copied!");
            }
        }
        else
        {
            info("Canceled by user");
        }
        
       
    }

  • Ronak Brahmbhatt Profile Picture
    70 on at
    RE: AX 2009 Security: Copy From One User to Other (Thru X++ / Code )?

    Hi Andre,

    I agree with your though. The user groups are same for both users so they both should have same 'permissions'.

    Also, you are right with Module specific settings. 

    For example, User A can process Credit Card while User B can't.

    • Later, I figured that User B needs to be in added in CreditCardUsers table. 

    So, there may be a few more things like this which I need to tackle. I will continue to narrow it down.

    Thanks for your input.

  • Ronak Brahmbhatt Profile Picture
    70 on at
    RE: AX 2009 Security: Copy From One User to Other (Thru X++ / Code )?

    Hi Abdul,

    Thank you for this code. I wish I had this earlier when we were manually copying a few new users.

    Also, this one is specific to User Groups. Do you the backend object for 'Permissions'?

    Thanks again,

    Ronak

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans