Before you can access Microsoft Dynamics NAV you should be known as a user in the NAV database. (The only exception is when there a created no users at all then everyone will be granted access with SUPER permissions.) So when you haven’t been created (in NAV) as a user you will get the following warning when you try to access the database:
It’s really easy to fix this ‘problem’ with Powershell.
- Start Powershell ISE
- Import the NAV Administration Module
- Run the cmdlet to Add yourself to the NAV database and grant yourself Permissions with another Cmdlet, please see the complete code at the end of this post.
- Start the Windows Client (NAV)
I would recommend to use Powershell ISE. There are a lot of articles out there on the internet telling all the advantages it has.
How to import the NAV Administration Module:
Import-Module "$env:ProgramFiles\Microsoft Dynamics NAV\90\Service\NavAdminTool.ps1
Please mind that the module can only be loaded from the NAV Service Tier (NST) server, because the module is part of the NAV Administration Tools. Next, add the Windows Account you are using to start NAV with New-NAVServerUser:
New-NAVServerUser -ServerInstance $ServerInstance -WindowsAccount $WindowsAccount -Verbose
Adding yourself as a user isn’t enough. You also need to specify which permission you have in NAV (authorization). If you are created as a user and try to start NAV you will now get the following warning:
This means you have no or not enough permissions although NAV knows who you are (authenticated) but that doesn’t mean you have the permission to read/start/do anything. So, in this example we will give the Windows account SUPER permissions (the highest privilege) in NAV. You can do this in Powershell with the New-NAVServerUserPermissionSet Cmdlet:
New-NAVServerUserPermissionSet -ServerInstance $ServerInstance -WindowsAccount $WindowsAccount -Verbose
Please replace $WindowsAccount with the User you want to give access and replace $Serverinstance with the proper NAV Instance. Below an example script where you only have to replace the ServerInstance variable. The script is automatically retrieving your current domain name and username. Let PowerShell work for you as much as possible… :)
$WindowsAccount = "$env:userdomain\$env:USERNAME" $ServerInstance = "DynamicsNAV90" Import-Module "$env:ProgramFiles\Microsoft Dynamics NAV\90\Service\NavAdminTool.ps1" New-NAVServerUser -ServerInstance $ServerInstance -WindowsAccount $WindowsAccount -Verbose New-NAVServerUserPermissionSet -ServerInstance $ServerInstance -WindowsAccount $WindowsAccount -PermissionSetId 'SUPER' -Verbose
If you want to learn more about the NAV Security System please check MSDN ‘Security and Protection‘