RPC Server is unavailable by computers under xp

S

Stropher

I have the following code and if I enter the name of a computer running
under windows xp I get an exception that rpc server is not available
although the services are running

void userGroups(string computerName)

string compName = computerName;
if (!compName.StartsWith(@"\\"))
{
compName = @"\\" + compName + @"\root\cimv2";
}
ConnectionOptions options = new ConnectionOptions();

options.Username = this.userName;
options.Password = this.password;

ManagementScope mScope = new ManagementScope(compName, options);
string domain = "";
try
{
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(mScope,new ObjectQuery("SELECT * FROM
Win32_Group where Domain
= '" + computerName + "'"));
ManagementObjectSearcher searcher2 = new
ManagementObjectSearcher(mScope,new ObjectQuery("SELECT Name FROM
Win32_UserAccount where
Domain = '" + computerName + "'"));

ManagementObjectCollection moc = searcher.Get(); //***
//by *** jump into the exception
ManagementObjectCollection moc2 = searcher2.Get();

ManagementBaseObject[] names = new ManagementBaseObject
[moc2.Count];
ManagementBaseObject[] groups = new ManagementBaseObject
[moc.Count];
moc2.CopyTo(names, 0);
moc.CopyTo(groups, 0);

domain = groups[0]["Domain"].ToString();

for (int i = 0; i < groups.Length; i++)
{
if (i < names.Length)
{
string name = names["Name"].ToString();
this.listBoxBenutzername.Items.Add(name);
}

this.listBoxRechner.Items.Add(domain);
string group = groups["Name"].ToString();
this.listBoxGruppe.Items.Add(group);

}
}
}
catch (Exception ex)
{
throw new Exception("Error obtaining group names. " +
ex.Message);
}
}

---------------------------------------------
An this point, see //***
I get the exception: "RPC Server is unavailable from HRESULT:
0x800706BA"

Is there anything I am missing?
Thanks in advance
 
W

Willy Denoyette [MVP]

By default, XP and higer OS do not enable "external" access of WMI services.
You'll have to set each PC's WMI security according your requirements.

Willy.

|I have the following code and if I enter the name of a computer running
| under windows xp I get an exception that rpc server is not available
| although the services are running
|
| void userGroups(string computerName)
|
| string compName = computerName;
| if (!compName.StartsWith(@"\\"))
| {
| compName = @"\\" + compName + @"\root\cimv2";
| }
| ConnectionOptions options = new ConnectionOptions();
|
| options.Username = this.userName;
| options.Password = this.password;
|
| ManagementScope mScope = new ManagementScope(compName, options);
| string domain = "";
| try
| {
| ManagementObjectSearcher searcher = new
| ManagementObjectSearcher(mScope,new ObjectQuery("SELECT * FROM
| Win32_Group where Domain
| = '" + computerName + "'"));
| ManagementObjectSearcher searcher2 = new
| ManagementObjectSearcher(mScope,new ObjectQuery("SELECT Name FROM
| Win32_UserAccount where
| Domain = '" + computerName + "'"));
|
| ManagementObjectCollection moc = searcher.Get(); //***
| //by *** jump into the exception
| ManagementObjectCollection moc2 = searcher2.Get();
|
| ManagementBaseObject[] names = new ManagementBaseObject
| [moc2.Count];
| ManagementBaseObject[] groups = new ManagementBaseObject
| [moc.Count];
| moc2.CopyTo(names, 0);
| moc.CopyTo(groups, 0);
|
| domain = groups[0]["Domain"].ToString();
|
| for (int i = 0; i < groups.Length; i++)
| {
| if (i < names.Length)
| {
| string name = names["Name"].ToString();
| this.listBoxBenutzername.Items.Add(name);
| }
|
| this.listBoxRechner.Items.Add(domain);
| string group = groups["Name"].ToString();
| this.listBoxGruppe.Items.Add(group);
|
| }
| }
| }
| catch (Exception ex)
| {
| throw new Exception("Error obtaining group names. " +
| ex.Message);
| }
| }
|
| ---------------------------------------------
| An this point, see //***
| I get the exception: "RPC Server is unavailable from HRESULT:
| 0x800706BA"
|
| Is there anything I am missing?
| Thanks in advance
|
 
J

Jeff Shepler

Make sure the firewall isn't blocking it.

Also, you need to set an additional option. Since sp1, it has been
required to use PacketPrivacy when authenticating against remote
machines. You just need to set an additional ConnectionOption. In you
code, add:

options.Authentication = AuthenticationLevel.PacketPrivacy;


You should also be aware of the behavior that RPC uses dynamic port
allocation. I don't know if this is the case for XP boxes, but if you
ever want to do what you're doing to a server, you will probably need
to know this:

http://support.microsoft.com/kb/154596/EN-US/
 
S

Stropher

Thanks Jeff for your reply...

Jeff said:
Make sure the firewall isn't blocking it.

Also, you need to set an additional option. Since sp1, it has been
required to use PacketPrivacy when authenticating against remote
machines. You just need to set an additional ConnectionOption. In you
code, add:

options.Authentication = AuthenticationLevel.PacketPrivacy;


You should also be aware of the behavior that RPC uses dynamic port
allocation. I don't know if this is the case for XP boxes, but if you
ever want to do what you're doing to a server, you will probably need
to know this:

http://support.microsoft.com/kb/154596/EN-US/




I have the following code and if I enter the name of a computer running
under windows xp I get an exception that rpc server is not available
although the services are running

void userGroups(string computerName)

string compName = computerName;
if (!compName.StartsWith(@"\\"))
{
compName = @"\\" + compName + @"\root\cimv2";
}
ConnectionOptions options = new ConnectionOptions();

options.Username = this.userName;
options.Password = this.password;

ManagementScope mScope = new ManagementScope(compName, options);
string domain = "";
try
{
ManagementObjectSearcher searcher = new
ManagementObjectSearcher(mScope,new ObjectQuery("SELECT * FROM
Win32_Group where Domain
= '" + computerName + "'"));
ManagementObjectSearcher searcher2 = new
ManagementObjectSearcher(mScope,new ObjectQuery("SELECT Name FROM
Win32_UserAccount where
Domain = '" + computerName + "'"));

ManagementObjectCollection moc = searcher.Get(); //***
//by *** jump into the exception
ManagementObjectCollection moc2 = searcher2.Get();

ManagementBaseObject[] names = new ManagementBaseObject
[moc2.Count];
ManagementBaseObject[] groups = new ManagementBaseObject
[moc.Count];
moc2.CopyTo(names, 0);
moc.CopyTo(groups, 0);

domain = groups[0]["Domain"].ToString();

for (int i = 0; i < groups.Length; i++)
{
if (i < names.Length)
{
string name = names["Name"].ToString();
this.listBoxBenutzername.Items.Add(name);
}

this.listBoxRechner.Items.Add(domain);
string group = groups["Name"].ToString();
this.listBoxGruppe.Items.Add(group);

}
}
}
catch (Exception ex)
{
throw new Exception("Error obtaining group names. " +
ex.Message);
}
}

---------------------------------------------
An this point, see //***
I get the exception: "RPC Server is unavailable from HRESULT:
0x800706BA"

Is there anything I am missing?
Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top