Link to home
Start Free TrialLog in
Avatar of Uncle_Chunky
Uncle_ChunkyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Getting the security descriptor of a folder on a remote machine

Hi,

I am trying to get the security descriptor of a folder on a remote machine with the following code:

*********************************************

On Error Resume Next

strServerName = Server123
strWMIGenSharePath = E:\\Data\\Test

Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strServerName & "\root\cimv2")
Set objShareSec = objWMI.Get("Win32_LogicalFileSecuritySetting.Path=" & Chr(34) & strWMIGenSharePath & Chr(34))
Set retVal = objShareSec.GetSecurityDescriptor(objSD)
If Err <> 0 Then
    WScript.Echo "GetSecurityDescriptor failed" _
    & VBCRLF & Err.Number & VBCRLF & Err.Description
    WScript.Quit
Else
    WScript.Echo "GetSecurityDescriptor succeeded"
End If

*********************************************

I get the following error:

GetSecurityDescriptor failed
424
Object required

So it seems that it is not finding the Win32_LogicalFileSecuritySetting class for the folder but if I echo out the properties they do seem valid:

objShareSec.caption                            "Security settings of E:\DATA\Test"
objShareSec.controlflags                     "32772"
objShareSec.description                      "Security settings of E:\DATA\Test"
objShareSec.ownerpermissions          "-1"
objShareSec.path                                 "E:\DATA\Test"
objShareSec.settingid                           "null"

Can anyone explain what is happening here please?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Uncle_Chunky

ASKER

Yes, thanks. It was definitely a single quote issue. The following lines are now working okay for me.
Set objShareSec = objWMI.Get("Win32_LogicalFileSecuritySetting='" & strWMIGenSharePath & "'")
retVal = objShareSec.GetSecurityDescriptor(objSD) 

Open in new window

Thanks for the points! Happy new year!