Thursday 27 September 2018

Dynamics CRM : Export Security Role


In CRM as a developer sometime we need to see permission given to Security role.
Dynamics CRM/365 we need to open security role to check permission in that security role.
But there is no provision to export Security role permission.

Case Study: -
Developer X is working in an organization as support engineer. He was not part of implementation team.
User requested role given in each security role permission in excel sheet.
It is time consuming job to open each security role and make excel sheet manually with all permission.

Solution: -
To tackle this case study, I have created a XrmToolBox Plugin which help Developer X.
User can see permission given in each security role to entity.
User can see Miscellaneous Privileges.
User can export all Privileges based on selected Security role.
Download XRMToolBox from given URL and install. https://www.xrmtoolbox.com/
Install “Export Security Role” Plugin in your XRMTollBox using plugin store.























If you are not able to find “Export Security Role in Xrmtoolbox.
Use below links
Download Plugin compatible with Xrmtoolbox Version 1.2019.7.34 from here:
Download 1.2019.11.15

Download Xrmtoolbox Version 1.2019.7.34 from here:
XrmToolbox v1.2019.7.34

And download plugin from here. Install in XRMToolBox by clicking Settings->Path->Storage folder->Plugin folder.
Copy assemblies in Plugin folder.









































Connect your organization and open plugin Export Security Role.













Click on “Retrieve Roles” and select your security Role.
Now you will see list of all security roles in role list.





Now when you select any security role it will show all Privileges for selected security role.

































If need to search specific entity enter logical name in search box.











Click on Export button to export privileges in excel.
















As a result, you will see a excel file with Security role name is create with all privileges.





























Now Developer X will easily able to find and share permission based on security role.

Note: - Plugin based on .net framework 4.5.2. Microsoft office required to export result.

Follow my blog so you will not miss my new upcoming blogs.

44 comments:

  1. I like that the visibility to Teams and Users that the security role is assigned to are shown. However, just clicking on a Business Unit and a Security Role did not show any of the permissions on the screen as shown in your explanation. What did I miss?

    ReplyDelete
  2. Hey Santosh thank you for your effort! I did experience the same thing. All permissions are either set as "None" or "Organization", with no "Business Unit" or "User" or "Parent: Child Business Units" values.

    ReplyDelete
    Replies
    1. Hi Hani,
      Thanks for reply.
      I have verified your reply and I can see other permission also like "user", "business unit". Try with other security role.
      Miscellaneous privileges can be organization only.

      Delete
  3. Hi Santosh, even i faced the same issue, either its organization or none, other privileges are not showing up.

    ReplyDelete
    Replies
    1. Issue is fixed now and latest code in avaliable in given link.
      Please try and share your comment.
      https://github.com/santoshCRM/Export-Security-Role/blob/master/Assembly.zip

      Delete
  4. Hi Santosh, I'm not able to get the plugin to show up in the xrmtoolbox store. Is it still publsihed? If so, do you have more instructions how to add it?

    ReplyDelete
    Replies
    1. Hi Bassio,
      I think xrmtoolbox yet not verifed plugin. I have shared plugin source in download link https://github.com/santoshCRM/Export-Security-Role/blob/master/Assembly.zip
      You can download and add in your plugin folder.

      Delete
    2. Hi Santosh,

      After downloading the Assembly file and added dll in plugin folder, i am not able to find plugin in the store to install. Export security role plugin is not available in the list

      Delete
    3. Once you add plugin folder you should able to see this plugin in your list of plugins.

      Use below link to get updated plugin
      https://github.com/santoshCRM/Export-Security-Role/blob/master/Savants.ExportSecurityRole%20v1.2019.11.15.zip

      This plugin compatible with xrmtoolbox version 1.2019.7.34

      Delete
  5. Hi Folks,

    Issue is fixed now and latest code in avaliable in given link.
    Please try and share your comment.
    https://github.com/santoshCRM/Export-Security-Role/blob/master/Assembly.zip

    ReplyDelete
  6. Issue is fixed now and latest code in avaliable in given link.
    Please try and share your comment.
    https://github.com/santoshCRM/Export-Security-Role/blob/master/Assembly.zip

    ReplyDelete
  7. When i try to export is showing this error: Is not working, Helppppp please

    System.Runtime.InteropServices.COMException (0x8002000B): El índice no es válido. (Excepción de HRESULT: 0x8002000B (DISP_E_BADINDEX))
    en Microsoft.Office.Interop.Excel.Sheets.get__Default(Object Index)
    en ExportSecurityRole.ExportRole.btn_Export_Click(Object sender, EventArgs e)
    en System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
    en System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
    en System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
    en System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
    en System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
    en System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    en System.Windows.Forms.Control.WndProc(Message& m)
    en System.Windows.Forms.ToolStrip.WndProc(Message& m)
    en System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    ReplyDelete
    Replies
    1. Make sure you have installed Microsoft office 365. and try again.

      Delete
    2. Nice, i have a question, Should I have Office 365 installed offline

      Delete
    3. Yes, Or you can download zip file from
      https://github.com/santoshCRM/Export-Security-Role/blob/master/Assembly.zip
      It have required office DLL

      Delete
  8. When I try to export is showing this error, could you help me please

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.Runtime.InteropServices.COMException (0x8002000B): Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
    at Microsoft.Office.Interop.Excel.Sheets.get__Default(Object Index)
    at ExportSecurityRole.ExportRole.btn_Export_Click(Object sender, EventArgs e)
    at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
    at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
    at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
    at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
    at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ToolStrip.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    ReplyDelete
    Replies
    1. you can download zip file from
      https://github.com/santoshCRM/Export-Security-Role/blob/master/Assembly.zip
      It have required office DLL

      Delete
  9. I'm getting this erros
    Ocorreu uma exceção sem tratamento no aplicativo. Se você clicar em Continuar, o aplicativo ignorará esse erro e tentará continuar. Se clicar em Encerrar, o aplicativo será encerrado imediatamente.

    Índice inválido. (Exceção de HRESULT: 0x8002000B (DISP_E_BADINDEX)).
    Consulte o final desta mensagem para obter detalhes sobre como chamar a
    depuração just-in-time (JIT) em vez desta caixa de diálogo.

    ReplyDelete
    Replies
    1. you can download zip file from
      https://github.com/santoshCRM/Export-Security-Role/blob/master/Assembly.zip
      It have required office DLL

      Delete
  10. Hi Santosh, i am getting below error while retrieving the roles.

    Unable to cast object of type 'Microsoft.Xrm.Tooling.Connector.CrmServiceClient' to type 'Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy'.

    ReplyDelete
    Replies
    1. It seems you are not using updated XRMToolbox.
      Update your Xrmtoolbox and
      you can download zip file from
      https://github.com/santoshCRM/Export-Security-Role/blob/master/Assembly.zip
      It have required office DLL

      Delete
    2. I am using the updated Xrmtoolbox but still getting the same error.I tried downloading the zip file you said above and added those dll's from the assembly folder to XRM tool box extracted folder, still no luck. Please assist.

      Delete
  11. Hi Santosh, This error is resolved but another error occurring for one of the custom Entity

    "An error occurred: An error occurred while parsing EntityName. Line 1, position 302."

    ReplyDelete
  12. you can download zip file from
    https://github.com/santoshCRM/Export-Security-Role/blob/master/Assembly.zip
    It have required office DLL

    Can you try with Trail instance first for more comparison.

    ReplyDelete
  13. Hi Santosh, I´m getting an error retrieving roles with your Export Security Role:


    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Tooling.Connector.CrmServiceClient' to type 'Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy'.
    at ExportSecurityRole.Helper.createConn(IOrganizationService Service)
    at ExportSecurityRole.ExportRole.btn_retRole_Click(Object sender, EventArgs e)
    at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
    at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)

    ReplyDelete
    Replies
    1. Use Xrmtool box version XrmToolBox v1.2019.2.32
      Download from :- https://www.xrmtoolbox.com/releases/

      Delete
  14. Hi, im having the same problem as guys above me.

    Unable to cast object of type 'Microsoft.Xrm.Tooling.Connector.CrmServiceClient' to type 'Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy'.

    Can you help us, please?

    ReplyDelete
    Replies
    1. Use Xrmtool box version XrmToolBox v1.2019.2.32
      Download from :- https://www.xrmtoolbox.com/releases/

      Delete
  15. Use Xrmtool box version XrmToolBox v1.2019.2.32
    Download from :- https://www.xrmtoolbox.com/releases/

    ReplyDelete
  16. i get this error when hit "retrieve roles"

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Tooling.Connector.CrmServiceClient' to type 'Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy'.
    at ExportSecurityRole.Helper.createConn(IOrganizationService Service)
    at ExportSecurityRole.ExportRole.btn_retRole_Click(Object sender, EventArgs e)
    at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
    at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
    at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
    at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
    at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ToolStrip.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


    ************** Loaded Assemblies **************
    mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.7.3416.0 built by: NET472REL1LAST_B
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
    ----------------------------------------

    WHAT SHOULD I DO WITH THE OFFICE FILE?

    ReplyDelete
  17. Hello, so the latest release of XRMTB (currently 1.2019.7.34) wont work?

    ReplyDelete
    Replies
    1. No, it this need to update plugin. will update once get some time.

      Delete
  18. Hi XrmToolBox v1.2019.2.32 is no longer available for download.
    With version 1.2019.7.34 I am getting the same error.
    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Tooling.Connector.CrmServiceClient' to type 'Microsoft.Xrm.Sdk.Client.OrganizationServiceProxy'.
    at ExportSecurityRole.Helper.createConn(IOrganizationService Service)
    at ExportSecurityRole.ExportRole.btn_retRole_Click(Object sender, EventArgs e)
    at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
    at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
    at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
    at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
    at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ToolStrip.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    ReplyDelete
  19. Hi Mate, I followed your steps and when I clicked on the Retrive Roles, I got the assembly error.

    ReplyDelete
    Replies

    1. at ExportSecurityRole.Helper.createConn(IOrganizationService Service)
      at ExportSecurityRole.ExportRole.btn_retRole_Click(Object sender, EventArgs e)
      at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
      at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
      at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
      at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
      at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
      at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
      at System.Windows.Forms.Control.WndProc(Message& m)
      at System.Windows.Forms.ToolStrip.WndProc(Message& m)
      at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

      Delete
    2. Use below link to get updated plugin
      https://github.com/santoshCRM/Export-Security-Role/blob/master/Savants.ExportSecurityRole%20v1.2019.11.15.zip

      This plugin compatible with xrmtoolbox version 1.2019.7.34

      Delete
  20. Hi Santosh, thank you so much for this great and helpful tool. Would really appreciate it if you'll consider adding the Entity Display Name in the future. :)

    ReplyDelete
    Replies
    1. Thanks for recommendations, This feature enable now

      Delete
  21. Are there known issues with the latest Microsoft 365 Apps for Enterprise (Office 365 Excel). Every time I try to export, I get a text file stating "Error occured while exporting security role, Close all excel sheets and try again"

    ReplyDelete
  22. Are there aby solution for these error messages:
    Warning Settings not fountd => a new settings file has been created!
    Error Error occured while exporting security role, Close all excel sheets and try again.

    ReplyDelete
  23. Hi Santosh,
    Great app but i'm running with above mentioned error

    "2021-02-12 05:02:03.489 CRM Test Error Error occured while exporting security role, Close all excel sheets and try again"

    Did i something wrong or do you have a solution for this?
    Regards

    ReplyDelete
    Replies
    1. New plugin release for same. Use Role Documenter now.

      Delete
  24. Hi Santosh, great job on the Role Documenter tool!
    Unfortunately it seems that, when I create an export, a few privileges are missing. For a custom role I created there are some privileges under the Business Mgmt and Service tab that are not in the export file.

    Is there a known bug?

    Thanks!
    Timothy

    ReplyDelete

Field Security Profile - Based on Owner

 Recently received requirement related to Field security profile. Expectation : - 1.       Set to users need access of secure attributes. 2....

Test