Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7889103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:00:38+00:00 2026-06-03T06:00:38+00:00

Context: Windows7 64bit, ActiveDirectory, Windows Server 2003 I’m trying to get the code given

  • 0

Context: Windows7 64bit, ActiveDirectory, Windows Server 2003

I’m trying to get the code given by Microsoft on their page GetSecurityDescriptor method of the Win32_Printer Class (Windows) to work. I’m a bit curious to know how the double instantiation of winmgmts works out, viz (from their code)

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate, (Security)}!\\" & strComputer & "\root\cimv2")

Set objWMIService = GetObject("winmgmts:")

I would have thought that the second instance would clobber the first. This would seem to be borne out by the fact that no matter what server name I put in strComputer, I still get a list of the printers on my computer.

Has anyone had any joy getting the DACL of a server-connected printer using VBScript?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:00:39+00:00Added an answer on June 3, 2026 at 6:00 am

    you are right and there is more than one thing wrong with that script, here is a working version

    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
    

    =>> on my domain this gives the ACL twice per user, could be caused by the way security is given

    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
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Context We have a SharePoint site set up on a Windows Server 2008 VM
Context Language: C# Platform Version: Microsoft .Net Framework 4.0 Operating System: Windows 7 Professional
I am trying to invoke an ANT target from Windows (right-click) file context menu.
Context: Windows7, VBScript, ADODB and ADOX. I have written some VBScript code which creates
I'm trying to get the value of another process' EBP register on windows7 64
I can create a menu item in the Windows Explorer context menu by adding
How would one go about adding a submenu item to the windows explorer context
As the context menu for the desktop and explorer windows is disabled, I wanted
OK, first for context look at the Windows desktop; You can take items (folders,
What's the difference between System.Drawing.Point and the System.Windows.Point ? In what context should which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.