4 Replies Latest reply: Aug 21, 2007 8:44 AM by Newsgroup_User RSS

    cfdirectory to network locations

    Dan Bracuk Community Member
      The long term objective is to be able to use cffile to write text files to various servers and I am trying to figure out the syntax with cfdirectory. Here is the code.

      <cfset thedir = "something">
      <cfdirectory directory="#thedir#" name="x" action="list">
      <cfdump var="#x#">

      In the first set, if I set the variable to anything resembling "drive_letter\directory\subdirectroy\etc", I see the contents of the directory. So far so good.

      The problem is, whenever I anything else, I get nothing. Some of my unsuccessful attempts include:

      http://server_name/directory/
      http://ip_address/directory/
      as above without http:
      \\server_name\directory\
      \\ip_address\directory

      Am I attempting something that is even possible? If it's possible, is my lack of success because of my code or because of permissions?
        • 1. Re: cfdirectory to network locations
          johnab Community Member
          it will definitely be a permissions thing. By default CF (on windows) runs as the System user which has no priviledges over a network. It's a pretty easy problem to solve - assuming your CF server and the servers you want to access are in the same domain (or forest) then you simply change your CF service to start as a domain user and then give that new user account permission to your local websites as well as your folders (and shares).
          • 2. Re: cfdirectory to network locations
            Newsgroup_User Community Member
            johnab wrote:
            > By default CF (on windows) runs as the System user

            i believe you meant LOCAL, not System?


            --

            Azadi Saryev
            Sabai-dee.com
            http://www.sabai-dee.com
            • 3. Re: cfdirectory to network locations
              Newsgroup_User Community Member
              "Am I attempting something that is even possible? If it's possible, is
              my lack of success because of my code or because of permissions?"


              It is quite possible - I do stuff like this all the time. Your problem
              is most likely the latter. In order for this to work, you must make
              sure that the ColdFusion application server is running as a user that
              has the appropriate permissions to the resources you want it to access.

              By default CF runs as a 'local system' user which usually has
              permissions to the local server and nothing else. On a windows system
              this would be changing the user that the CF application server service
              runs under in the "Service" panel to a user defined with the appropriate
              permissions.

              Once this is done, code such as this will work fine <cfdirectory
              directory="//server-name/directory/"...>.
              • 4. Re: cfdirectory to network locations
                Newsgroup_User Community Member
                if you put the name of server CF is running on into \\server\somedir\
                path, you can see that cfdirectory will happily return its contents =>
                look at permissions
                --

                Azadi Saryev
                Sabai-dee.com
                http://www.sabai-dee.com