1. Dave Contessi
  2. PowerBuilder
  3. Thursday, 5 September 2019 16:05 PM UTC

We have a requirement to copy files from the client to file server using PB app.  When using FileCopy() I see the file ownership on the file server is of the PB app user.  We need to change the file ownership to another windows account for security reasons.

I would appreciate some ideas on how to handle this within PB app if possible.

 

 

Regards

 

Roland Smith Accepted Answer Pending Moderation
  1. Thursday, 5 September 2019 16:43 PM UTC
  2. PowerBuilder
  3. # 1

You might be able to convert one of the following to PB. They might be changing to the current user, I didn't look too close.

VB6:

https://support.microsoft.com/en-us/help/318744/how-to-use-visual-basic-to-programmatically-change-ownership-of-a-file

C++

https://docs.microsoft.com/en-us/windows/win32/secauthz/taking-object-ownership-in-c--

If you were to HTTP POST the file as a blob to a web service that you wrote, it could then write it to the file server. I am pretty sure that would make the owner IIS_USR.

 

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 5 September 2019 18:22 PM UTC
  2. PowerBuilder
  3. # 2

Hi Dave;

   After the FileCopy has completed successfully, just call the DOS Command "TakeOwn.exe".

For example:  takeown /f /r /d y

FYI: https://theitbros.com/using-takeown-exe-command-to-take-ownership-of-file-or-folder/

HTH

Regards ... Chris

 

 

Comment
  1. Roland Smith
  2. Thursday, 5 September 2019 18:49 PM UTC
Quoting that page: "Using the takeown command, you can change object ownership and assign it only to the current user or the local administrator group. The command doesn’t allow you to specify an arbitrary user or group as the owner of the directory or file."

The file is already owned by the current user so that won't help.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Thursday, 5 September 2019 19:44 PM UTC
Hi Roland;

That would be correct from the WorkStation perspective. I was thinking that after the FileCopy, maybe calling a Web Service on the Server that would then execute the TakeOwn command. Thus, IIS_User would become the owner. One could also implement a batch App that runs on the server that executes the TakeOwn command under "Admin" user (or whatever) account control.

Regards ... Chris
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 6 September 2019 04:12 AM UTC
  2. PowerBuilder
  3. # 3

what about not using a webservice and temporarily mapping a network drive to the folder of the file and then using takeown.exe?

I mean by using a .cmd or .bat file with something like this:

 

net use q: \\tower\movies /user:miguel mypassword /persistent:No
takeown /f /r /d y ....
net use q: /delete

The only thing is that you'd have to first find a letter for a drive that hasn't been used yet.
Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.