khuemmeler Posted February 25, 2019 Share Posted February 25, 2019 Hi all, I need to save some XML-Files to a network-share, like \\servername\sharename , which has also login credentials. This must be done within a unigui service application. Any help appreciated! Thanks in advance! Regards Klaus Quote Link to comment Share on other sites More sharing options...
wprins Posted February 25, 2019 Share Posted February 25, 2019 Does your service run standalone or under e.g. IIS? (Obviously the simplest is for the service to be set to run under an account with write rights to the share.) Quote Link to comment Share on other sites More sharing options...
khuemmeler Posted February 26, 2019 Author Share Posted February 26, 2019 It's a standalone Windows-Service. But the login account can't be the same account, which has rights for the share. A persistant mapping seems not to work inside the service. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 26, 2019 Share Posted February 26, 2019 @Khuemmeler In Service mode, without account write rights, destination folder must be in : PublicDocuments IMHO (In my humble opinion) So, Copying your XML in : \\Server\users\....\PublicDocuments Where, of course PublicDocument is shared (in group residential) Regards. Quote Link to comment Share on other sites More sharing options...
khuemmeler Posted February 27, 2019 Author Share Posted February 27, 2019 Solved by using this code-snippet: function MakeDriveMapping(DriveLetter: string; DirectoryPath: string; Username: string; Password: string; RestoreAtLogon: Boolean): DWORD; var NetResource: TNetResource; dwFlags: DWORD; begin with NetResource do begin dwType := RESOURCETYPE_DISK; lpLocalName := PChar(DriveLetter); lpRemoteName := PChar(DirectoryPath); lpProvider := nil; end; if (RestoreAtLogon) then dwFlags := CONNECT_UPDATE_PROFILE else dwFlags := 0; Result := WNetAddConnection2(NetResource, PChar(Password), PChar(Username), dwFlags); end; 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.