Options

Run C/AL code in different user context (impersonation)?

Markus_HMarkus_H Member Posts: 8
edited 2015-04-29 in NAV Three Tier
Hello,

I've got a simple question: Is there a way to run certain lines of code in another user's context? I want to store files, that my users upload via the windows client, on the file system, but do not want to give every single user access to the folder the files are stored. So I would like to write and get those files in the context of a technical user or system user. Like the "run with elevated priviliges" pattern in SharePoint, if somebody knows.

Thanks in advance,

Markus

[NAV2013R2]

Comments

  • Options
    lvanvugtlvanvugt Member Posts: 774
    Hi Markus,

    Haven't needed to do this before, but my thought go in the direction of using the job queue.
    Luc van Vugt, fluxxus.nl
    Never stop learning
    Van Vugt's dynamiXs
    Dutch Dynamics Community
  • Options
    Markus_HMarkus_H Member Posts: 8
    Hi Luc,

    for the direction of storing the files, that could be a way. But they should also be retrieved from their location in an "elevated" context without having every user given read permissions to the filesystem.

    Perhaps there is a way to do this with .net and System.IO? I'll do some research about it...

    Thanks,

    Markus
  • Options
    Rob_HansenRob_Hansen Member Posts: 296
    How is this structured? Is the user requesting/accessing these files through NAV? If so, then rather than running things client-side, you can use a server/network folder that is accessible by the account running the NAV server. When the user wants to open a file, the NAV server can retrieve it from the folder and download it to the client to open up. The user doesn't need access to the server/network folder.
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Impersonation is very easy in C#.

    For a project with Anveo in classic client I've created a download that does this.

    http://mibuso.com/dlinfo.asp?FileID=1587

    Not sure if this would work with Dotnet interop, but you can try, or just update the dll to work with a newer version of NAV.

    Good luck.
Sign In or Register to comment.