How to get current Windows Login (different of logged to db)
AntidotE
Member Posts: 61
Hello,
3rd-party application pulls data to the database table, which contains windows login (there are several connections to database, so this app can't decide, what user is needed).
My code has to react to data in updated table, and if it belongs to needed user (currently logged to windows) - open specific form.
I need to find what user is logged in windows now.
NAV provides logged into database in Session table.
Environ('USERNAME') contains completely different stuff ('SYSTEM' on every computer under every user in our case).
e.g. I logged to windows under domain\User1, then used database login User2 to connect to database. Session table will show User2, not domain\User1. USERID will show User2.
Does anybody know how to?
Thanks!
[updated] see solving message
3rd-party application pulls data to the database table, which contains windows login (there are several connections to database, so this app can't decide, what user is needed).
My code has to react to data in updated table, and if it belongs to needed user (currently logged to windows) - open specific form.
I need to find what user is logged in windows now.
NAV provides logged into database in Session table.
Environ('USERNAME') contains completely different stuff ('SYSTEM' on every computer under every user in our case).
e.g. I logged to windows under domain\User1, then used database login User2 to connect to database. Session table will show User2, not domain\User1. USERID will show User2.
Does anybody know how to?
Thanks!
[updated] see solving message
It is hard to swim against self bloodstream... (c) Old, experienced kamikadze.
0
Answers
-
2 options:
1. Let users login to NAV using NT Authentication mode
2. Use WScript object and UserName property http://msdn.microsoft.com/en-us/library/3fxhka75(v=VS.85).aspx There are lot of examples how to use script objects in NAV.Sincerely yours, GRIZZLY
Follow my blog at http://x-dynamics.blogspot.com0 -
Thanks! :thumbsup:
some windows users can't connect to database with their logins due to some security, but can use internal database login, which is different in USERID from windows login. This is customer... :roll:GRIZZLY wrote:1. Let users login to NAV using NT Authentication mode
seem to work! at least with developer's licenseGRIZZLY wrote:2. Use WScript object and UserName property http://msdn.microsoft.com/en-us/library/3fxhka75(v=VS.85).aspx There are lot of examples how to use script objects in NAV.
some code to put in memory:NetWorkShell Automation 'Windows Script Host Object Model'.WshNetwork GetLoggedWindowsUser() Result : Text[250] IF CREATE(NetWorkShell) THEN BEGIN Result := STRSUBSTNO('%1\%2',NetWorkShell.UserDomain,NetWorkShell.UserName); END ELSE ERROR('Could not create automation instance to get User Name.'); CLEAR(NetWorkShell);It is hard to swim against self bloodstream... (c) Old, experienced kamikadze.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
- 322 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