Access Username & Password protected folder share (Windows) through NAV 5.0

Hi there,

I want to automatically (no user interaction!) save a file to a network shared folder that is not inside the same Domain as the NAV 5.0 Client.

If you access the folder through the explorer you'd need to enter the credentials (Window pops up). How can I achieve that (Establish connection, login, save file) in C/AL? Couldn't find anything related to that.

Thanks very much in advance!

Best Answer


  • archer89archer89 ViennaMember Posts: 337
    with .net classes it can be done with the following.
    in your case you need to use automations instead.

    NetworkCredential := NetworkCredential.NetworkCredential(username, password, domain); //2. domain
    CredentialCache := CredentialCache.CredentialCache;
    Uri := Uri.Uri('\\server');
    CredentialCache.Add(Uri, 'Basic', NetworkCredential);
    Dirs := SysDir.GetDirectories('\\server\directory');
    FOR i:=1 TO Dirs.GetLength(0) DO
    DirListTxt := DirListTxt + FORMAT(Dirs.GetValue(i-1))+'\'; //.net index starts with 0
    MESSAGE(DirListTxt); // print out the dir list

    NetworkCredential DotNet System.Net.NetworkCredential.'System
    CredentialCache DotNet System.Net.CredentialCache.'System
    Uri DotNet System.Uri.'System
    Dirs DotNet System.Array.'mscorlib
    SysDir DotNet System.IO.Directory.'mscorlib
    DirListTxt Text
    i Integer
    best regards
    Franz Kalchmair, MVP
    Alias: Jonathan Archer

    please like / agree / verify my answer, if it was helpful for you. thx.
  • HarakiriHarakiri Member Posts: 6
    edited 2018-12-10
    @archer89 unfortunately that does not work with NAV 5.0. There's no automation available that can be used.

    @lubost your answer worked but it's like a big workaround :)
Sign In or Register to comment.