Options

How to get the windows login name

Daniel86Daniel86 Member Posts: 13
Hi,

many users in my company, use the same Super-User-ID. So you can't say which user is logged in exactly.
What i want to do is, to lock the database for user B, while user A is performing an update. But when user A and user B are using the same login, i can't use the login name. So i decided to use the windows login name as a clear definition. But i don't know how to get the windows login name.
Can you help me? :roll:

Thanks!

Comments

  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I suggest you create a new super-user ID for user A and set an expiration date on the super-user ID for user B. This way, user A can login with the new ID and perform the update, while user B is not able to login.

    After the update, you can remove the expiration date and delete the new super-user ID.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    Daniel86Daniel86 Member Posts: 13
    Thanks for your fast answer.
    I also thought this would be a great solution, but the problem is,
    that i don't want to create more work for the user who's performing
    the update. I want to create a solution which rules that automatically.
  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Is it more work for the user who's performing the update to use a different User ID to login?

    The new User ID can be created in advance. And the expiration date can be set in advance too.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    Daniel86Daniel86 Member Posts: 13
    Hmmm...sounds good, but you'll have to change the expiration date each time you perform an update, or?
  • Options
    PoltergeistPoltergeist Member Posts: 200
    A simple answer to your question: The Windows username can be retrieved with ENVIRON('username').
  • Options
    Daniel86Daniel86 Member Posts: 13
    That's exactly what i was searching for. Thanks a lot!
  • Options
    munnimunni Member Posts: 22
    A simple answer to your question: The Windows username can be retrieved with ENVIRON('username').
    for windows user name where should i write ENVIRON('username') this code?
    im new to navision just tell me where should i write the above code?
    thanq
    kavi
  • Options
    Daniel86Daniel86 Member Posts: 13
    That depends on where you want to use the login name.
    For example, when you want to use it in a report, you should write it in the

    "Report - OnPreReport" - trigger

    'cause that's one of the first called triggers. So you can use the Windows Login name (if you wrote it in a global variable) in the whole report.

    Hope i could help.
  • Options
    Captain_DX4Captain_DX4 Member Posts: 230
    munni wrote:
    for windows user name where should i write ENVIRON('username') this code?
    im new to navision just tell me where should i write the above code?
    thanq
    kavi

    In most instances, you should be able to just use the USERNAME function within Navision to get it to display the current user in reports. This will work when you have separate users setup in your Navision security, unless you've got an "interesting" setup like Daniel86 *hehe*.

    It would be recommended that, whenever possible, separate security setups be created for each user with a separate Navision user id (database or windows), at least in the interest of security concerns and to comply with laws like Sarbanes Oxley *waves to US friends*. Obviously this is much harder to administer, but this is easiest to maintain proper security.
    Kristopher Webb
    Microsoft Dynamics NAV Developer
Sign In or Register to comment.