How to know computer name that access SQL Server via remote

johanna
Member Posts: 369
Dear all,
When I am on computer A, I remote computer B and open Microsoft SQL Server Management Studio (SQL Server 2005).
On computer B, I have used 'sys.dm_exec_sessions' and got the result that the host name is computer B. How to know that SQL is accessed from computer A via remote access with SQL query?
Thanks before
When I am on computer A, I remote computer B and open Microsoft SQL Server Management Studio (SQL Server 2005).
On computer B, I have used 'sys.dm_exec_sessions' and got the result that the host name is computer B. How to know that SQL is accessed from computer A via remote access with SQL query?
Thanks before

Best regards,
Johanna
Johanna
0
Comments
-
I doubt very much SQL is able to find that using system views or tables.
I guess you will need to make a stored procedure that is using some Citrix or Remote Desktop API to find the actual client. I'll suggest a Citrix or Remote Desktop forum instead.
But it would be great if you share it here if you find a solution - I'm sure other NAV developers could use itRegards
Peter0 -
Hi Peter,
Thank you for your suggestion..
I will try to ask in Citrix or Remote Desktop forum..
Sure, I will share it here if I find a solution..
Once again, thank you Peter..Best regards,
Johanna0 -
I don't think if it is possible at all to do it right. You may try to employ some WMI Queries from T-SQL..
If you think of it T-SQL queries are executed at SQL server machine. So the code (even .NET CLR) has access to SQL Server environment.
You may want to use HOST_NAME() in T_SQL to get machine from which the connection to SQL Server was made. Yet it will be Citrix/RDP server name, not the local workstation from where connection to Windows/Citrix server was initiated.
In case of Citrix/Windows2008 there is environment variable CLIENTNAME storing current workstation name from where ICA/RDP connection has been initiated. So tracing back connection to the Citrix/terminal server (using HOST_NAME()), then retrieving list of logged users, finding 'your' user environmnet (using remote WMI Query), then examining CLIENTNAME environment variable could get original workstation name.
But... what if the same user is logged twice on the same Citrix/terminal server ? From two different machines ? What if connection to Citrix/Windows was made from another RDP/Citrix connection ?
Perhaps writing your own .NET CLR assembly would be the simplest option, at least getting access to various internal system data or using WMI would be fairly simple
Anyway - have fun
SlawekSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Hi Slawek,
Thank you for your suggestion.. I really appreciate it..
It looks like complicated to know computer name that access SQL Server via remote.
I'll try it later if I have free enough time.
Thanks again! ^^Best regards,
Johanna0
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