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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 09.06.2011, 01:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,491 / 846 (79) +++++++
Регистрация: 28.10.2006
Rahul Sharma: Change File Ownership through X++ in Dynamics AX
Источник: http://feedproxy.google.com/~r/Rahul...h-x-in_06.html
==============

This article shows a little trick that might be needed for testing AX AIF file adapter based integration. We all know that how frustrating it can be to setup input file ownership to current AX user while testing otherwise AX will complain about it.

Here is a small static function with filepath as a parameter. This function will set current AX user as the owner of the input file. This function can be called right before the call to fileSystem.ReadFile(filePath) in \Classes\AifFileSystemReceiveAdapter\readFile.

X++:
   1:  static client protected void SetFileOwnership2CurUser(FilePath _filePath)
   2:  {
   3:      UserInfo                                            userInfo;
   4:      System.IO.FileInfo                                  fileInfo;
   5:      System.Security.AccessControl.FileSecurity          fileSecurity;
   6:      System.Security.Principal.SecurityIdentifier        sid;
   7:      System.Security.AccessControl.AccessControlSections acSections;
   8:      ;
   9:   
  10:      //select current user
  11:      select userInfo
  12:          where userInfo.Id == curuserid();
  13:   
  14:      try
  15:      {
  16:          new InteropPermission(InteropKind::ClrInterop).assert();
  17:          fileInfo           = new System.IO.FileInfo(_filePath);
  18:          acSections      = System.Security.AccessControl.AccessControlSections::Owner;
  19:          fileSecurity       = fileInfo.GetAccessControl(acSections);
  20:          sid = new System.Security.Principal.SecurityIdentifier(userInfo.sid);
  21:          //set ownership
  22:          fileSecurity.SetOwner(sid);
  23:          fileInfo.SetAccessControl(fileSecurity);
  24:          CodeAccessPermission::revertAssert();
  25:      }
  26:      catch
  27:      {
  28:          throw error(AifUtil::getClrErrorMessage());
  29:      }
  30:  }


Join me on facebook | twitter | linkedin !!!






Источник: http://feedproxy.google.com/~r/Rahul...h-x-in_06.html

Последний раз редактировалось Poleax; 09.06.2011 в 10:47. Причина: оформление
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Rahul Sharma: Change File Ownership through X++ in Dynamics AX Blog bot DAX Blogs 0 07.06.2011 01:12
axinthefield: Dynamics AX Event IDs Blog bot DAX Blogs 0 01.03.2011 22:11
daxdilip: Whats New in Dynamics AX 2012 (A brief extract from the recently held Tech Conf.) Blog bot DAX Blogs 7 31.01.2011 12:35
semanticax: Dynamics AX 2009 Installation - Application Blog bot DAX Blogs 0 22.12.2010 08:11
axStart: Microsoft Dynamics AX 2009 Hot Topics Web Seminar Series Blog bot DAX Blogs 0 06.08.2008 12:05

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

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

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