You do not have access to Microsoft Dynamics NAV. Verify that you have been set up as a valid user in Microsoft Dynamics NAV.

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:

User Not Created

If you want to learn more about the NAV Security System please check MSDN ‘Security and Protection

It’s really easy to fix this ‘problem’ with Powershell. Global steps:

  • Start Powershell ISE
  • Import the NAV Administration Module
  • Run Cmdlet to Add yourself to the NAV database and grant yourself Permissions with another Cmdlet.
  • 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:

No Permissions

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

 

 

Advertisements

SQL Server Database States

In my daily job as a Technical Consultant I regularly work with  NAV and the SQL databases it’s using . I’ve seen (or set SQL) databases in the following states (in SQL Server):

Read-Only The database can be set to this mode if the data shouldn’t be updated.
Single User In single user mode only one user is allowed acces. In some situations it’s neccesary to perform maintenance tasks in Single mode.
Restricted User In restricted user mode only users with the sysadmin or dbcreator role  can access the database.
Offline Database is not available for access.
Emergency In Emergency mode you can use DBCC CHECKDB to bring the database back online again.
Recovery Pending If for example the logfile is damaged or corrupted, the database will be in this state. Action by the DBA is needed to resolve the error.

In SSMS2016 (SQL Server Management Studio 2016):

Database States in SQL 2016

Note: this is not an exhausting list of all the states. My advice is to check the File States Article on MSDN  for more information. Please also use Google for more advanced information about other database states like ‘Suspect’,’Recovery Pending’ etc.

For some states to enable I’ve used TSQL. Below you can find them:

CREATE DATABASE [Demo Database NAV (9-0) DB2]
ALTER DATABASE [Demo Database NAV (9-0) DB2] SET SINGLE_USER

CREATE DATABASE [Demo Database NAV (9-0) DB3]
ALTER DATABASE [Demo Database NAV (9-0) DB3] SET RESTRICTED_USER

CREATE DATABASE [Demo Database NAV (9-0) DB4]
ALTER DATABASE [Demo Database NAV (9-0) DB4] SET Offline

CREATE DATABASE [Demo Database NAV (9-0) DB5]
ALTER DATABASE [Demo Database NAV (9-0) DB5] SET Emergency

Configuration and personalization in NAV 2016

The Role Tailored Client (RTC) or Windows Client for Dynamics NAV 2016 has a different Role Center for each type of User. Everytime you start NAV this page will be your ‘starting point’. For example, if a user has the Profile ‘Order Processor’ then he or she will see the ‘Order Processor’ role center. So the interface is RoleTailored to the user as much as possible.  This Role Center reflects his/her tasks, views and priorities. It’s possible however to change the default ‘look and feel’ by customizing the Role Center. You could for example hide or display elements in your NAV ribbon or change the visibility of fields, actions, factboxes or fasttabs. By default personalization is enabled. It’s possible to disable personalization by adding the -disablepersonalization parameter. Example:

"C:\Program Files (x86)\Microsoft Dynamics NAV\90\RoleTailored Client\Microsoft.Dynamics.Nav.Client.exe" -disablepersonalization

Note: if you disable personalization it’s still possible to change the width of your columns for example. These settings are saved locally to ‘PersonalizationStore.xml’. This file can be found in the Appdata folder, example: ‘C:\Users\YourUsername\AppData\Roaming\Microsoft\Microsoft Dynamics NAV’. In  NAV 2009 the column width was stored in a ZUP file.

Besides user personalization it’s also possible to use the ‘Configuration Mode’. Configuration Mode allows configuration for a NAV Profile. So after customizing a profile the changes will affect all users who are assigned to this profile. This ‘base layer’ of customizations could then be personalized by the user. But it’s also possible to prevent this so your users can’t personalize NAV. This way you could protect users from their selves and assure that all users of a certain profile see the same buttons, field etc. This could ease support tasks for example.

In order to work in configuration mode to customize a profile you need to specify the parameter -configure. Example:

"C:\Program Files (x86)\Microsoft Dynamics NAV\90\RoleTailored Client\Microsoft.Dynamics.Nav.Client.exe" -configure

For more information you could also visit MSDN ‘How to: Open Microsoft Dynamics NAV in Configuration Mode

Another way to disable profile personalization for users: Go to: Departments/IT Management/RoleTailored Client/Profiles. Next, select the Disable Personalization checkbox for the profile you want to disable personalization.

Disable Personalization

Invoke-WebRequest – Download files with PowerShell – Improved script!

A few months further I’ve learned and read some new things about Powershell and also about this Cmdlet. This resultated in an improved script compared to my old post Invoke-WebRequest. I just want to share it so maybe you can benefit from it too. The script now uses the Join-Path and Split-Path Cmdlets and a Leaf parameter. This results in more efficiënt code. I’ve also written a small feature which measures the time it took to download the file and also I’ve builtin some error handling because IF the download fails I don’t want to see the message ‘.NET Framework 4.6 download completed’ rather something like this ‘Something went wrong’. The PowerShell language is amazingly powerful!

$Uri = "https://download.microsoft.com/download/C/3/A/C3A5200B-D33C-47E9-9D70-2F7C65DAAD94/NDP46-KB3045557-x86-x64-AllOS-ENU.exe"
$DownloadFileName = Split-Path $Uri -Leaf
$OutFile = Join-Path "$env:USERPROFILE" -ChildPath "Desktop"
$OutFile += "\$DownloadFileName"
$Timestamp = Get-Date
try 
{
Invoke-WebRequest -Uri $Uri -OutFile $OutFile
Write-Host "Download completed. It took $((Get-Date).Subtract($Timestamp).Minutes) minutes and $((Get-Date).Subtract($Timestamp).Seconds) seconds ."
}
catch
{
Write-Host "Something went wrong."
}