あなたは正しいです、そしてそのスクリプトには複数の問題があります、ここに作業バージョンがあります
SE_DACL_PRESENT = &h4
ACCESS_ALLOWED_ACE_TYPE = &h0
ACCESS_DENIED_ACE_TYPE = &h1
strComputer = "xxxxxxxxxx"
strUser = "xxxxxxxxxxxx"
strPassword = "xxxxxxx"
strDomain = "xxx"
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer(strComputer, _
"root\cimv2", _
strUser, _
strPassword, _
"MS_409", _
"ntlmdomain:" + strDomain)
Set colInstalledPrinters = objSWbemServices.ExecQuery ("Select * from Win32_Printer")
On error resume next
For Each objPrinter in colInstalledPrinters
Wscript.Echo "Name: " & objPrinter.Name
Return = objPrinter.GetSecurityDescriptor( objSD )
If ( return = 2 ) Then
WScript.Echo "Could not get security descriptor: " & Return
Elseif ( return = 8 ) Then
WScript.Echo "Unknown failure: " & Return
Elseif ( return = 9 ) Then
WScript.Echo "The user does not have adequate privileges to execute the method: " & Return
Elseif ( return = 21) Then
WScript.Echo "A parameter specified in the method call is not valid: " & Return
Elseif ( return = 0 ) Then
intControlFlags = objSD.ControlFlags
If intControlFlags AND SE_DACL_PRESENT Then
arrACEs = objSD.DACL
For Each objACE in arrACEs
WScript.Echo objACE.Trustee.Domain & "\" & objACE.Trustee.Name
If objACE.AceType = ACCESS_ALLOWED_ACE_TYPE Then
WScript.Echo vbTab & "User has access to printer"
ElseIf objACE.AceType = ACCESS_DENIED_ACE_TYPE Then
WScript.Echo vbTab & "User does not have access to the printer"
End If
Next
Else
WScript.Echo "No DACL found in security descriptor"
end if
Else
WScript.Echo "Could not get security descriptor: " & Return
End If
Next
= >>私のドメインでは、これによりユーザーごとに2回ACLが提供されます。これは、セキュリティの提供方法が原因である可能性があります。
Name: printer1
\CREATOR OWNER
User has access to printer
\CREATOR OWNER
User has access to printer
MCM\DomainUsers
User has access to printer
MCM\DomainUsers
User has access to printer
MCM\DomainUsers
User has access to printer
MCM\admin
User has access to printer
MCM\admin
User has access to printer
BUILTIN\Administrators
User has access to printer
BUILTIN\Administrators
User has access to printer