7 Replies Latest reply on Sep 8, 2016 4:57 PM by John Groft

    GetFileCopy Issues

    John Groft

      Hi Everyone,

      I'm running into an issue with the GetFileCopy() method.  I've got a class that I use for working with EPDM.  One of the methods within that class (GetLatestVersion) uses GetFileCopy() to copy the latest version of a file to the local cache.  This method works just fine when I call it from a WPF application.  However, I'm trying to use it within a WCF web service hosted in IIS and it times out.  It doesn't 'fail' - no error is generated; it just doesn't finish.  I ran into a similar issue with LoginEx() but that was just permissions.  Now the login works and so do calls to get search results etc., but GetFileCopy() is giving me problems.

       

      Now, the first parameter of GetFileCopy()  is actually supposed to be the parent window handle.  In IIS, there is no interactive session, so I don't have a window handle to pass.  I'm just passing zero instead.  I'm not sure if that's the source of the issue.  I've seen a number of examples on the web where zero is passed as the parameter, but none of the examples that I've seen specify whether they're being run in a WPF/Windows Forms application or if they're in web service, etc.

       

      Has anyone tried this before?  Any insights?  This is my last obstacle so I'm hoping someone else has run into this and resolved it.

        • Re: GetFileCopy Issues
          Jesse Seger

          I'm not sure, but I can assure you that it has nothing to do with the window handle. 

            • Re: GetFileCopy Issues
              John Groft

              Thanks, Jesse. 

               

              Tracking down the exact issue is tough because there's no information returned.  It seems really odd to me that this one method is failing and that, for some reason, its only required parameter is a window handle.  It seems like an odd requirement unless the intent is to display something in or over the specified window.  I had to at least explore the possibility - especially when the same call works fine in an interactive application versus a service. 

               

              Any idea why it requires a window handle?  I don't see any info in the API docs. 

            • Re: GetFileCopy Issues
              Lee CS Young

              I remember running into this when using web services a few years ago. It comes down to permissions. You'll need the app pool to run on a domain account if I recall correctly.

               

              iis - How to Enable File System Access to Web Service? - Stack Overflow

                • Re: GetFileCopy Issues
                  John Groft

                  Hmmm... That makes a lot of sense.  It feels like a permissions issue - even though I'm not getting an actual error.  I had this same issue with LoginEx(), but couldn't get it to run until I changed the application pool to login as NetworkService.  (By default, IIS uses AppPoolIdentity).  Incidentally, EPDM's own web service runs under NetworkService.  So everything works up to the point where it hits GetFileCopy().  Then it fails in the same way that LoginEx() originally did.

                   

                  I did try creating a folder on the C: drive, giving NetworkService full permissions to it and then passing parameters to GetFileCopy() telling it to place the files there, but no luck.  If I change the app pool to run under a domain ID that has access to both the vault and the file system, LoginEx() stops working.  So there's probably some additional level of security that I'm missing.

                    • Re: GetFileCopy Issues
                      Lee CS Young

                      Have you tried LoginAuto or Login to rule out LoginEx? I don't think you need to use LoginEx if you already login to the vault view locally, which can be done via a login script or start up item and you shouldn't be breaking the EULA.

                        • Re: GetFileCopy Issues
                          John Groft

                          Yes, actually, I have.  I tried it again too after seeing this message just to make sure that I tried it while logged into the vault view.  It generates a "Can't open database" error.

                           

                          Ultimately, I wanted LoginEx because I didn't want to rely on having someone manually (or via script) logged into EPDM on the web server when LoginEx can do it for me - though I'd certainly change that approach if one of the others worked.  The service does work nicely under NetworkService - for everything except GetFileCopy. 

                           

                          I also modified the application pool to load the user profile - not that NetworkService has one - but it uses a temporary.  That actually caused GetFileCopy to return an Access Denied error instead of just timing out.  That felt like progress.  Then I noticed after the change that GetFileCopy was generating DCOM errors on the server security log.  It didn't have permission to locally launch AddInRegSvr32 or AddInsRegSvr64.  Just to see if it solved the problem, I temporarily granted access for NetworkService to launch those components and the security errors went away, but GetFileCopy just went back to timing out.  Since it didn't solve the problem, I backed out those changes for now.

                           

                          Sooo... That brings me back to permissions.  It seems that NetworkService has some permission that my AD account doesn't have - one that allows LoginEx to run.  If I can figure out what that is and create a domain account with the same permission AND access to the file system, maybe I can get this thing working.  I'm just not sure what that is at the moment.