Changing File Ownership 
Author Message
 Changing File Ownership

Is it possible to programatically change the owner of a file using VBScript?
I can add a security entry to the ACL on a file, but I do not see how to
change the ownership of the file.

Thanks in advance for any help you can provide.



Sun, 30 Nov 2003 23:00:51 GMT  
 Changing File Ownership
As far as NTFS ownership of file system objects is concerned, you cannot
'give' or 'assign' ownership to another user. You can only 'take' ownership.
But you can assign the 'Take Ownership' permission to another user (or
group) account, which in turn allows that user to take ownership of the
object.

The only way any user can (in your words) 'change the owner of a file',
whether it be in script or otherwise, is by taking ownership of that file.
In this case, the user is changing the owner of the file to himself.

John Avitt, MCSE


Is it possible to programatically change the owner of a file using vbscript?
I can add a security entry to the ACL on a file, but I do not see how to
change the ownership of the file.

Thanks in advance for any help you can provide.



Mon, 01 Dec 2003 00:06:15 GMT  
 Changing File Ownership
Thanks for the explanation.

I guess I should be more specific.  I am looking to do via vbscript
something similar to what the resource kit utility SUBINACL does.  It allows
you to set the owner of a file (as long as the user specied as the new owner
has the ability to 'take ownership' of the file).  So, how do I 'take
ownership' of a file via vbscript?  Or is this not possible?


Quote:
> As far as NTFS ownership of file system objects is concerned, you cannot
> 'give' or 'assign' ownership to another user. You can only 'take'
ownership.
> But you can assign the 'Take Ownership' permission to another user (or
> group) account, which in turn allows that user to take ownership of the
> object.

> The only way any user can (in your words) 'change the owner of a file',
> whether it be in script or otherwise, is by taking ownership of that file.
> In this case, the user is changing the owner of the file to himself.

> John Avitt, MCSE



> Is it possible to programatically change the owner of a file using
vbscript?
> I can add a security entry to the ACL on a file, but I do not see how to
> change the ownership of the file.

> Thanks in advance for any help you can provide.



Mon, 01 Dec 2003 00:39:28 GMT  
 Changing File Ownership
I am not familiar with SUBINACL but, if you have access to that utility, I
would think that you could use it with the WshShell.Run method.

I think it likely that ADSI provides a method for this, although I am not
familiar enough with it to know. I am going to check into it further.


Thanks for the explanation.

I guess I should be more specific.  I am looking to do via vbscript
something similar to what the resource kit utility SUBINACL does.  It allows
you to set the owner of a file (as long as the user specied as the new owner
has the ability to 'take ownership' of the file).  So, how do I 'take
ownership' of a file via vbscript?  Or is this not possible?


Quote:
> As far as NTFS ownership of file system objects is concerned, you cannot
> 'give' or 'assign' ownership to another user. You can only 'take'
ownership.
> But you can assign the 'Take Ownership' permission to another user (or
> group) account, which in turn allows that user to take ownership of the
> object.

> The only way any user can (in your words) 'change the owner of a file',
> whether it be in script or otherwise, is by taking ownership of that file.
> In this case, the user is changing the owner of the file to himself.

> John Avitt, MCSE



> Is it possible to programatically change the owner of a file using
vbscript?
> I can add a security entry to the ACL on a file, but I do not see how to
> change the ownership of the file.

> Thanks in advance for any help you can provide.



Mon, 01 Dec 2003 01:28:57 GMT  
 Changing File Ownership
------------------
If you've installed and registered ADsSecurity.DLL from the SDK, you can
manipulate the Owner property of the Security Descriptor, then update it
with IADsSecurityUtility::SetSecurityDescriptor method.
------------------
++++++++++++++++++++++++++++++
Option Explicit
Dim sec, sd

Set sec = Wscript.CreateObject("ADsSecurity")
Set sd = sec.GetSecurityDescriptor("FILE://c:\test\test")

wScript.Echo "Control Flag: " & sd.Control & vbCrLf & "Group Owner: " & _
 sd.Group & vbCrLf & "Owner: " & sd.Owner & vbCrLf & _
 "SD Revision: " & sd.Revision

sd.Owner="<DOMAIN>\newowner"   'I've only tried the "standard Windows"
syntax
sec.SetSecurityDescriptor sd

Set sec = Nothing
Set sec = Wscript.CreateObject("ADsSecurity")
Set sd = sec.GetSecurityDescriptor("FILE://c:\test\test")

wScript.Echo "Control Flag: " & sd.Control & vbCrLf & "Group Owner: " & _
 sd.Group & vbCrLf & "Owner: " & sd.Owner & vbCrLf & _
 "SD Revision: " & sd.Revision

++++++++++++++++++++++++++++++


Quote:
> Is it possible to programatically change the owner of a file using
vbscript?
> I can add a security entry to the ACL on a file, but I do not see how to
> change the ownership of the file.

> Thanks in advance for any help you can provide.



Fri, 12 Dec 2003 22:20:33 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Changing form ownership

2. NT4: change ownership and permissions

3. ACC97 OS level File Ownership

4. Taking file ownership (NT4 + NTFS)

5. Determining file ownership

6. Visual basic and NT file ownership

7. How to Read File Ownership on NTFS

8. Taking file ownership (NT4 + NTFS)

9. Take ownership of a file

10. file ownership from Novell volumes

11. disk quotas and files ownership

12. File Ownership

 

 
Powered by phpBB® Forum Software