SQL Script for Account Level Security
I recently joined Microsoft as a Partner Consultant for the Global Partner Services team. I have been associated for more than 8 years in the design, development and implementation of Microsoft Dynamics GP in India, Middle East and US. This is my first post in this blog and it feels great to be posting alongside community experts like David Musgrave, Patrick Roth and others.
Microsoft Dynamics GP offers the Account Level Security option to restrict the access of GL accounts to specific users. There is no specific report (or) Smartlist which is available for viewing the details of the accounts which each user has access to.
The script below gives us the details of the various users in the system and the accounts they have access to. If a user does not have access to any accounts, the user will not be listed in the results.
Code Example
/******************************************************************
Created Jun 23, 2012
This script is used for generate the details of users and the
GL accounts which they have access to, when account level security
is activated in Dynamics GP.
Tables Used:
GL00100F1 - Account Master Filter1
GL00100F2 - Account Master Filter2
GL00100F3 - Account Master Filter3
GL00100F4 - Account Master Filter4
GL00105 - Account Index Master
SY01400 - Users Master
Revision History
No. User Date Description
*******************************************************************/
SELECT C.USERID ,
LTRIM(RTRIM(B.ACTNUMST)) AS ACCOUNTNO
FROM ( SELECT ACTINDX ,
RELID
FROM dbo.GL00100F1
UNION ALL
SELECT ACTINDX ,
RELID
FROM dbo.GL00100F2
UNION ALL
SELECT ACTINDX ,
RELID
FROM dbo.GL00100F3
UNION ALL
SELECT ACTINDX ,
RELID
FROM dbo.GL00100F4
) A
INNER JOIN GL00105 B ON A.ACTINDX = B.ACTINDX
LEFT OUTER JOIN DYNAMICS..SY01400 C ON A.RELID = C.RELID
WHERE C.SECACCS = 0x00000000
UNION ALL
SELECT B.USERID ,
LTRIM(RTRIM(A.ACTNUMST)) AS ACCOUNTNO
FROM GL00105 A
CROSS JOIN DYNAMICS..SY01400 B
WHERE B.SECACCS = 0x01000000
The script is also available as an attachment at the bottom of this post.
We could also create a view based on this script and then create custom Smartlists using Smartlist Builder.
Hope this helps the community...
Until next post!
Siva
// Copyright © Microsoft Corporation. All Rights Reserved.
// This code released under the terms of the
// Microsoft Public License (MS-PL, https://opensource.org/licenses/ms-pl.html.)
Comments
Anonymous
July 02, 2012
Thanks for this.Anonymous
July 05, 2012
Nice article... Really a good to know post.Anonymous
July 06, 2012
Posting by Mark Polino at DynamicAccounting.net msdynamicsgp.blogspot.com.au/.../sql-script-for-account-level-security.htmlAnonymous
July 13, 2012
Thanks!!! Very useful!!!Anonymous
July 18, 2012
Posting from John Lowther at Microsoft Dynamics GP DBA community.dynamics.com/.../sql-script-for-account-level-security-developing-for-dynamics-gp-site-home-msdn-blogs.aspxAnonymous
April 16, 2015
Hey Siva, I wanted you to know that I loved your post! And that I did tweek it a little bit and reposted it. You can find my post giving you full credit located here: community.dynamics.com/.../great-sql-script-for-getting-which-users-have-access-to-which-accounts-when-using-account-level-security.aspx Again THANK YOU!!!!