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!
0
Answers
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
variables
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
Franz Kalchmair, MVP
Alias: Jonathan Archer
please like / agree / verify my answer, if it was helpful for you. thx.
Blog: http://moxie4nav.wordpress.com/
net use <drive letter> <path> /user <name> <password>
...do something
net use <drive letter> /delete
@lubost your answer worked but it's like a big workaround