none
WMI RRS feed

  • Question

  • There are printers added on the remote machine. 
    I am using the following code to return the list of printers on this REMOTE machine.

    Question:
    Do you know why this code does NOT return the name of the printers?
    Thanks

    //list of remote printers...
                string strWapiServer = "\\\\" + txtServerName.Text;

                ConnectionOptions options = new ConnectionOptions();
                options.Username = "username";
                options.Password = "password";
                options.Authority = "NTLMDOMAIN:omniad";
               
                ManagementScope myScope = new ManagementScope(strWapiServer + "\\root\\cimv2", options);
                SelectQuery oQuery = new SelectQuery("SELECT * FROM WIN32_Printer");
                ManagementObjectSearcher oResults = new ManagementObjectSearcher(myScope, oQuery);
                           
                //Iterate through printers...
                foreach (ManagementObject oItem in oResults.Get())
                {
                    string strPrinterName = oItem.Properties["DeviceID"].Value.ToString();
                }

    Tuesday, September 30, 2008 10:05 AM

Answers

  • Hi,

    here an excerpt from the article I posted before:

    Setting DCOM Security to Allow a User to Access a Computer Remotely

    Security in WMI is related to connecting to a WMI namespace. WMI uses DCOM to handle remote calls. One reason for failure to connect to a remote computer is due to a DCOM failure (error "DCOM Access Denied" decimal -2147024891 or hex 0x80070005). For more information about DCOM security in WMI for C++ applications, see Setting Client Application Process Security.

    You can configure DCOM settings for WMI using the DCOM Config utility (DCOMCnfg.exe) found in Administrative Tools in Control Panel. This utility exposes the settings that enable certain users to connect to the computer remotely through DCOM. Members of the Administrators group are allowed to remotely connect to the computer by default. With this utility you can set the security to start, access, and configure the WMI service.

    The following procedure describes how to grant DCOM remote startup and activation permissions for certain users and groups. If Computer A is connecting remotely to Computer B, you can set these permissions on Computer B to allow a user or group that is not part of the Administrators group on Computer B to execute DCOM startup and activation calls on Computer B.

    To grant DCOM remote launch and activation permissions for a user or group

    1. Click Start, click Run, type DCOMCNFG, and then click OK.
    2. In the Component Services dialog box, expand Component Services, expand Computers, and then right-click My Computer and click Properties.
    3. In the My Computer Properties dialog box, click the COM Security tab.
    4. Under Launch and Activation Permissions, click Edit Limits.
    5. In the Launch Permission dialog box, follow these steps if your name or your group does not appear in the Groups or user names list:
      1. In the Launch Permission dialog box, click Add.
      2. In the Select Users, Computers, or Groups dialog box, add your name and the group in the Enter the object names to select box, and then click OK.
    6. In the Launch Permission dialog box, select your user and group in the Group or user names box. In the Allow column under Permissions for User, select Remote Launch and select Remote Activation, and then click OK.
    And please check, if the DCOM service is running on the server.


    Best Regards,
    Ilija


    • Marked as answer by jack 321 Friday, October 3, 2008 5:23 AM
    Wednesday, October 1, 2008 11:14 AM

All replies

  • Hi,

    do you get any error messages ? An exception or something ? To what OS do you connect (Windows Server 2003, 2000) ? Have you checked your DCOM and COM security settings ?

    Please check out this article:

    http://msdn.microsoft.com/en-us/library/aa393266.aspx

    Best Regards,
    Ilija

    Wednesday, October 1, 2008 10:55 AM
  • Operating system on the target machine which I am investigating is windows server 2003 SP2. No error message is given.
    I do not know how to check for the security settings of DCOM and COM
    Any suggestions please?
    Wednesday, October 1, 2008 11:01 AM
  • Hi,

    here an excerpt from the article I posted before:

    Setting DCOM Security to Allow a User to Access a Computer Remotely

    Security in WMI is related to connecting to a WMI namespace. WMI uses DCOM to handle remote calls. One reason for failure to connect to a remote computer is due to a DCOM failure (error "DCOM Access Denied" decimal -2147024891 or hex 0x80070005). For more information about DCOM security in WMI for C++ applications, see Setting Client Application Process Security.

    You can configure DCOM settings for WMI using the DCOM Config utility (DCOMCnfg.exe) found in Administrative Tools in Control Panel. This utility exposes the settings that enable certain users to connect to the computer remotely through DCOM. Members of the Administrators group are allowed to remotely connect to the computer by default. With this utility you can set the security to start, access, and configure the WMI service.

    The following procedure describes how to grant DCOM remote startup and activation permissions for certain users and groups. If Computer A is connecting remotely to Computer B, you can set these permissions on Computer B to allow a user or group that is not part of the Administrators group on Computer B to execute DCOM startup and activation calls on Computer B.

    To grant DCOM remote launch and activation permissions for a user or group

    1. Click Start, click Run, type DCOMCNFG, and then click OK.
    2. In the Component Services dialog box, expand Component Services, expand Computers, and then right-click My Computer and click Properties.
    3. In the My Computer Properties dialog box, click the COM Security tab.
    4. Under Launch and Activation Permissions, click Edit Limits.
    5. In the Launch Permission dialog box, follow these steps if your name or your group does not appear in the Groups or user names list:
      1. In the Launch Permission dialog box, click Add.
      2. In the Select Users, Computers, or Groups dialog box, add your name and the group in the Enter the object names to select box, and then click OK.
    6. In the Launch Permission dialog box, select your user and group in the Group or user names box. In the Allow column under Permissions for User, select Remote Launch and select Remote Activation, and then click OK.
    And please check, if the DCOM service is running on the server.


    Best Regards,
    Ilija


    • Marked as answer by jack 321 Friday, October 3, 2008 5:23 AM
    Wednesday, October 1, 2008 11:14 AM
  • Thanks
    Friday, October 3, 2008 7:25 AM