1

I'm installing the service as a remotemachine user in the same workgroup because the service running as localmachine user does not have rights to access a network location.

enter image description here

I have a desktop application that sets the network location in the service.But before allowing the user to set a specific network location in the service,i need to check if the UNC Path entered by the user is accessible by the service. How can i check it from the Desktop Application?

Currently i use the following code to do simple directory exists check from the Desktop Application,obviously this does not confirm whether the service has access to the folder.

DirectoryInfo info = new DirectoryInfo(uncpath);
if (info2.Exists)
{
return true;
}
techno
  • 6,100
  • 16
  • 86
  • 192
  • So what is the question here? Do you want a confirmation if this is the best approach? – Praveen Paulose Sep 01 '18 at 08:04
  • @PraveenPaulose Well the code does not validate if the Network location is accessible by the service.It only checks from the perspective of the currently logged in local machine user. – techno Sep 01 '18 at 08:06
  • You could look at impersonation when trying to check the UNC. https://stackoverflow.com/questions/1232120/c-how-to-logon-to-a-share-when-using-directoryinfo – Praveen Paulose Sep 01 '18 at 08:09
  • @PraveenPaulose The code shows 'service does not exist exception' – techno Sep 01 '18 at 08:35

0 Answers0