NAV User on SQL trigger

fzarateo
Member Posts: 10
Hi all,
we have this situation on migration database.
With NAV 2009 we have SQL triggers to manage changes that could be replicated on other databases. And we have USERID from navision because our customer uses Classic client.
On nav 2015 with RTC we have the problem that the same triggers works fine but the user is always the user that start services.
How can we know who is the user that run this triggers from SQL?
Thanks in advance for your help
we have this situation on migration database.
With NAV 2009 we have SQL triggers to manage changes that could be replicated on other databases. And we have USERID from navision because our customer uses Classic client.
On nav 2015 with RTC we have the problem that the same triggers works fine but the user is always the user that start services.
How can we know who is the user that run this triggers from SQL?
Thanks in advance for your help
0
Comments
-
You cannot.
I heard that someone made somthing I think in DOTNET to catch the user before the transaction starts. Still have to look at that solution.0 -
can you try with SYSTEM_USER at the SQL trigger.aav!o0
-
Thanks for your response, but we try with this
SELECT ORIGINAL_LOGIN() as A,
SUSER_NAME(SUSER_ID()) as B,
SUSER_SNAME(SUSER_SID()) as C,
SYSTEM_USER as D,
CURRENT_USER as E,
USER_NAME(USER_ID()) as F,
SESSION_USER as G,
USER as H
INTO TablaT
And all results are the same, the user that start service.
We try with ssesion Id and table active session in nav, but the Id session in nav is not the same that SQL.0 -
You can use a following scenario:
1. Create a sql view to let Nav know the current sql process idcreate view [dbo].[sys_ConnectionProperties] as select cast(serverproperty('servername') as varchar(100)) as server_name, DB_NAME() as db_name, @@SPID as spid , system_USER as [system_user] GO
2. Create the linked sys_ConnectionProperties table in Nav.
3. Write a function to link the current Nav user to a server process id using an additional table.sys_ConnectionProperties.find('='); serverProcesses.spid=sys_ConnectionProperties.spid serverProcesses.navUser=USER(); if not serverProcesses.modify then serverProcesses.insert;
4. insert a function call in most suitable place - OnLoginStart or OnGlobalModify.
5. Modify SQL triggers.
6. Optimize the function - it's enough to modify serverProcesses table once per session.
Looking for part-time work.
Nav, T-SQL.0 -
Thanks for your help,
it works with little adjustments but the idea is great =D>0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions