Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Service access file on network folder

Service access file on network folder

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminsecurityhelpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    baerten
    wrote on last edited by
    #1

    Hello everybody, I created a service which runs nicely on my local machine. If I like to test an existence of a file, which is located on a network-folder (net use g: \\...) then the function _access returns me -1 (not exists). If I call exactly the same function with the same filename in a standard application (not as a service) then all works fine. Is it an access-security problem, or do I use simply the wrong function to test the existence of a file? (I don't wanted to use a fopen,fclose) Big thanks for any ideas :)

    G C B 3 Replies Last reply
    0
    • B baerten

      Hello everybody, I created a service which runs nicely on my local machine. If I like to test an existence of a file, which is located on a network-folder (net use g: \\...) then the function _access returns me -1 (not exists). If I call exactly the same function with the same filename in a standard application (not as a service) then all works fine. Is it an access-security problem, or do I use simply the wrong function to test the existence of a file? (I don't wanted to use a fopen,fclose) Big thanks for any ideas :)

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      what account is your service running under - default localsystem ? if so, you'll need to change that so that the account you run under has network access (localsystem by default does not have network access, this includes shares iirc).. create a dedicated account for your service, give it the correct access, its better than localsystem (if you google around a bit you should find more pointers on the same) 'g'

      1 Reply Last reply
      0
      • B baerten

        Hello everybody, I created a service which runs nicely on my local machine. If I like to test an existence of a file, which is located on a network-folder (net use g: \\...) then the function _access returns me -1 (not exists). If I call exactly the same function with the same filename in a standard application (not as a service) then all works fine. Is it an access-security problem, or do I use simply the wrong function to test the existence of a file? (I don't wanted to use a fopen,fclose) Big thanks for any ideas :)

        C Offline
        C Offline
        Covean
        wrote on last edited by
        #3

        If your service runs under the local system/local service account, it has no rights to access network resources. Try the network service user or create a new user and assign the login to this service.

        Greetings Covean

        1 Reply Last reply
        0
        • B baerten

          Hello everybody, I created a service which runs nicely on my local machine. If I like to test an existence of a file, which is located on a network-folder (net use g: \\...) then the function _access returns me -1 (not exists). If I call exactly the same function with the same filename in a standard application (not as a service) then all works fine. Is it an access-security problem, or do I use simply the wrong function to test the existence of a file? (I don't wanted to use a fopen,fclose) Big thanks for any ideas :)

          B Offline
          B Offline
          baerten
          wrote on last edited by
          #4

          Big thanks for your replies. That seems logic, but it doesn't work ... it's seriously a configuration problem. I'll make a workaround Thanks you two :)

          S 1 Reply Last reply
          0
          • B baerten

            Big thanks for your replies. That seems logic, but it doesn't work ... it's seriously a configuration problem. I'll make a workaround Thanks you two :)

            S Offline
            S Offline
            sashoalm
            wrote on last edited by
            #5

            Try to see what GetLastError returns immediately after the call to __access, it might tell you something. There's a tool in Visual Studio that will give you the error text for each error id.

            There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition. Blaise Pascal

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups