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

Harakiri
Member Posts: 8
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!
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
Best Answer
-
I used following scenario a years before:
net use <drive letter> <path> /user <name> <password>
...do something
net use <drive letter> /delete
5
Answers
-
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
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
best regards
Franz Kalchmair, MVP
Alias: Jonathan Archer
please like / agree / verify my answer, if it was helpful for you. thx.
Blog: http://moxie4nav.wordpress.com/1 -
I used following scenario a years before:
net use <drive letter> <path> /user <name> <password>
...do something
net use <drive letter> /delete
5
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions