Skip to main content

NAV 2013 & NAV 2013 R2 - You do not have access to Microsoft Dynamics NAV - Create User From SQL.

Hi all,

This post is based on suggestion from +Ami Paneri Upadhyay

* The Screen Shots and Query Applies - TO NAV 2013 R2. Steps Remain Same for NAV 2013 but query will get change.

* The Query for NAV 2013 can be found in my Skydrive, Link at the end of the post.

Let's see what was required and how we can achieve it.

CASE -

I received a database from customer and my windows login is not there in the database. I don't want to delete Customer Users from the database but want to add myself in the Users. How can we do this?

OR

We have a database internally for development. All the consultants having User ID's in the database are not available. I want to access the database, How can i achieve it?

If you are using NAV 2013 R2 or Higher Please refer this article.



What is the Error message?

Where i try to open the database i get below error from Role Tailored Client -

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



What we Want?

A) Add My Windows Login Details in User Table & User Property Table.
B) Add Role to My User in Access Control Table.

What are the Fields that are required to be filled in?

A) USER TABLE -

Below are the fields in USER TABLE.



The Problem that i see in this field list is of Field "Windows Security ID".

B) USER Property TABLE-

Below are the fields from USER Property Table.



All fields Look Good in this Table.

C)  Access Control Table -

Below are the fields from Access Control Table.



All fields Look Good in this Table.

So let's see How can i get "Windows Security ID" for my ID so that i can add same in User Table.

STEP 1 - HOW TO GET Windows Security ID or SSID

You can find so many ways to find it, but i find the Powershell as easy tool to find it.

1. Open Powershell.

2. Copy Below command in Command Window.
-----------------------------------------------------------
# Author - Saurav Dhyani
# BLOG - saurav-nav.blogspot.com
# Replace YourDomain\Your ID with your Domain Name & User Name

$objUser = New-Object System.Security.Principal.NTAccount("YourDomain\Your ID")

$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])
$strSID.Value
------------------------------------------------------------

Replace YourDomain\Your ID with Your Domain and USER ID.

Run the Command and in the Output Window you can see your SSID, as shown below.



Copy and Save the SSID, we will require it further.

STEP 2 - ENTER USER Details in NAVISION Database with Roles.

1. Open SQL Server Management Studio.

2. In My Case the database that i want to get access is Demo Database NAV (7-1).

3. Click on New Query and paste below listed command in the query window.

------------------------------------------------------------------------
-- Author - Saurav Dhyani
-- BLOG - saurav-nav.blogspot.com
-- APPLIES TO - NAV 2013 R2
-- Replace
-- DATABASE NAME - with your database name
-- YourDomain\Your ID - with your Domain Name & User Name
-- Your SSID - with SSID as copied in STEP 1

USE [DATABASE NAME]

DECLARE @USERSID uniqueidentifier, @WINDOWSSID nvarchar(119), @USERNAME nvarchar(50), @USERSIDTXT varchar(50)

SELECT NEWID()
SET @USERNAME   = 'YourDomain\Your ID'
SET @USERSID    = NEWID()
SET @USERSIDTXT = CONVERT(VARCHAR(50), @USERSID)
SET @WINDOWSSID = 'Your SSID'

INSERT INTO [dbo].[User]
          ([User Security ID],[User Name],[Full Name],[State],[Expiry Date],[Windows Security ID],[Change Password],[License Type]
          ,[Authentication Email])
    VALUES
          (@USERSID,@USERNAME,'',0,'1753-01-01 00:00:00.000',@WINDOWSSID,0,0,'')

INSERT INTO [dbo].[User Property]
          ([User Security ID],[Password],[Name Identifier],[Authentication Key],[WebServices Key],[WebServices Key Expiry Date],
          [Authentication Object ID])
    VALUES
          (@USERSID,'','','','','1753-01-01 00:00:00.000','')

INSERT INTO [dbo].[Access Control]
          ([User Security ID],[Role ID],[Company Name])
    VALUES
          (@USERSID,'SUPER','')
GO
------------------------------------------------------------------------
Replace

DATABASE NAME - with your database name
YourDomain\Your ID - with your Domain Name & User Name
Your SSID - with SSID as copied in STEP 1

Execute the Query and result we be something like as shown below.



Now if i try to Run the windows client i will be able to access same.

* The Query provide SUPER Role to user, if required you can change the Role in the Last part of the query.

THE Power shell command & SQL Queries can be downloaded from my SKYDRIVE.

File Names in Sky Drive - NAV 2013 & NAV 2013 R2 Add User to Database.rar

The Zip Folder Contain Below Listed Files -

-- Power Shell Command  - (Applies to NAV 2013 & NAV 2013 R2)
-- SQL Query - (Applies to NAV 2013)
-- SQL Query - (Applies to NAV 2013 R2)

Your Commands and feedback are much appreciated.

Thanks & Regards,
Saurav Dhyani
www.sauravdhyani.com

Comments

Popular posts from this blog

BC 21 and Higher - PowerShell Cmdlet (Replacement of Business Central Administration).

Hi Readers, As discussed in last article about deprecating of Business Central Administration, there are few common actions that we use in administration till Business Central 20. For our on-prem customers, we will still require doing activities. As Microsoft suggest we need to start using PowerShell cmdlet.    Let's see how to do those via PowerShell, or Administration Shell. I will be keep adding commands as you comment to this article.

Send Mail with Attachment From Navision.

Hi all, We have seen how to save a report into PDF and how to send mail to a customer. Let's link these two post in one i.e. Mailing statement to a customer into PDF Format. This article is part of the Series. Please Refer  Table of Content here . If you have the old objects set let me brief you what I will be changing - 

MSDYN365BC - Data Upgrade To Microsoft Dynamics 365 Business Central on premises.

Hi Readers, We have already talked about the number of steps for upgrading to Business Central on Premises from different NAV versions. After that article, I received multiple requests for an article which list down steps for Data Migration. In this article, we will discuss steps of data migration to MSDYN365BC (on-Prem) from NAV 2017. For this article, I am considering a Cronus Demo Database without any customization. For an actual upgrade project, we will have to complete object merge using compare and Merge process. After the Merge Process, the next step is data migration. Let's discuss those steps. Direct Upgrade to Microsoft Dynamics 365 Business Central (on-Prem) is from following versions - 1. NAV 2015. 2. NAV 2016. 3. NAV 2017. 4. NAV 2018.