G
Guest
On my Windows XP Tablet Edition and Windows XP Pro systems I can run this code:
public static void InstallPort( string printerIP, string portName,
string portNumber, string protocol )
{
ConnectionOptions options = new ConnectionOptions();
options.Impersonation =
System.Management.ImpersonationLevel.Impersonate;
ManagementPath basePath = new ManagementPath(@"\\.\ROOT\CIMV2");
ManagementPath win32Path = new
ManagementPath("Win32_TCPIPPrinterPort");
ManagementScope scope = new ManagementScope(basePath, options);
scope.Connect();
ManagementClass mc = new ManagementClass(scope, win32Path, new
ObjectGetOptions());
ManagementObject mo = mc.CreateInstance();
mo.Properties["Name"].Value = portName;
mo.Properties["HostAddress"].Value = printerIP;
mo.Properties["PortNumber"].Value = portNumber;
mo.Properties["Protocol"].Value = 1;
mo.Put();
}
And it installs a printer port on the system. If I run it on a Windows 2003
server, it fails and gives me "Access Denied" with this in the WMI log:
(Fri Oct 28 18:24:26 2005.1513609) : Error 80041003 occured executing
request for Win32_TCPIPPrinterPort.Name="IP_192.168.1.90"
(Fri Oct 28 18:24:26 2005.1513609) : CAsyncReq_PutInstanceAsync instance=
instance of Win32_TCPIPPrinterPort
{
HostAddress = "192.168.1.90";
Name = "IP_192.168.1.90";
PortNumber = 9000;
Protocol = 1;
};
in namespace root\cimv2 using flags 0x0
Does anyone know why I might get this? Does Windows 2003 Server have
enhanced security on WMI calls?
Thanks,
Chris
public static void InstallPort( string printerIP, string portName,
string portNumber, string protocol )
{
ConnectionOptions options = new ConnectionOptions();
options.Impersonation =
System.Management.ImpersonationLevel.Impersonate;
ManagementPath basePath = new ManagementPath(@"\\.\ROOT\CIMV2");
ManagementPath win32Path = new
ManagementPath("Win32_TCPIPPrinterPort");
ManagementScope scope = new ManagementScope(basePath, options);
scope.Connect();
ManagementClass mc = new ManagementClass(scope, win32Path, new
ObjectGetOptions());
ManagementObject mo = mc.CreateInstance();
mo.Properties["Name"].Value = portName;
mo.Properties["HostAddress"].Value = printerIP;
mo.Properties["PortNumber"].Value = portNumber;
mo.Properties["Protocol"].Value = 1;
mo.Put();
}
And it installs a printer port on the system. If I run it on a Windows 2003
server, it fails and gives me "Access Denied" with this in the WMI log:
(Fri Oct 28 18:24:26 2005.1513609) : Error 80041003 occured executing
request for Win32_TCPIPPrinterPort.Name="IP_192.168.1.90"
(Fri Oct 28 18:24:26 2005.1513609) : CAsyncReq_PutInstanceAsync instance=
instance of Win32_TCPIPPrinterPort
{
HostAddress = "192.168.1.90";
Name = "IP_192.168.1.90";
PortNumber = 9000;
Protocol = 1;
};
in namespace root\cimv2 using flags 0x0
Does anyone know why I might get this? Does Windows 2003 Server have
enhanced security on WMI calls?
Thanks,
Chris