AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
NAV
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 08.10.2014, 10:07   #1  
Blog bot is offline
Blog bot
Участник
 
25,487 / 846 (79) +++++++
Регистрация: 28.10.2006
Even though my blog queue has a lot of far more interesting todo entries waiting for their prime time, on my short flight to the Directions EMEA conference in Poznań, instead of dozing away or blank-staring through the window, I’ve decided to introduce the Microsoft.Dynamics.Nav.NavUserAccount.NavUserAccountHelper class, a part of the built-in .NET stack of Microsoft Dynamics NAV since the version 2013 R2. My friend, Eric, asked me to blog about it, so here it is, this post is for you, Eric.



For as long as I remember there was the USERID function in C/AL which allowed you to check the name of the current user. There were times when it was not particularly useful as it did not always provide all the content of the user account, but as NAV grew increasingly stronger integrated with Windows technology stack, and as we got new authentication options with NAV 2013, we needed more insight into the information related to the user account.

With NAV 2013 R2, and of course, NAV 2015, Microsoft Dynamics NAV brings a static .NET class named NavUserAccountHelper which contains some useful members to facilitate getting insight into user accounts, as well as controlling the authentication through O365 and Azure.

To declare a variable of this type, declare a DotNet variable, and then as a subtype, choose the following assembly:



And then choose the following type from it:



At this point, you have a variable which gives you access to a series of static methods (static means you don’t have to construct an instance first) to manage user authentication and related information:



Among the most interesting ones, I find the UserName function, which purports to be capable of converting an SID to a Windows account user name:



Let’s try to see if it does that:



And it shows this:



So far, so good. Just to see how smart it was, I created another Windows account to which I didn’t give any access to NAV or SQL Server, and then I wanted to see whether this function is smart enough to convert any SID to the username:



And it happily complies:



A couple of days ago, when cleaning up a system after an upgrade to NAV 2013 R2, there were a bunch of user profiles where we knew the SIDs of users, but didn’t know which user names these were, and we wanted to clean up the recycle bins for those users. This function came in handy to figure out who these users were. Funny enough, of all built-in Windows utilities, PowerShell and stuff, it was the .NET interop in NAV that proved the simplest to quickly turn a bunch of SIDs to full human-readable Windows user names.

I know, I know, it’s not that this is the most useful of all the functions of this class, but it’s very unlikely you’ll ever want to call other ones, except maybe for some purposes to check if an account is Windows, User Name or Access Control authentication, or if it is running on Azure, using one of the Is… ThisOrThat static methods.

If you are in Poznan, enjoy the conference, there will be a lot of great content there, and I am looking forward to meeting you there. And to you, Eric, thanks for all, and good luck!

Read this post at its original location at http://vjeko.com/blog/navuseraccounthelper-class, or visit the original blog at http://vjeko.com. 5e33c5f6cb90c441bd1f23d5b9eeca34</img> </img>

Читать дальше
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 19:17.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.