wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes List all local group members and add members to the local group on a remote machine using JAVA COM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "List all local group members and add members to the local group on a remote machine using JAVA COM" Watch "List all local group members and add members to the local group on a remote machine using JAVA COM" New topic
Author

List all local group members and add members to the local group on a remote machine using JAVA COM

giby mathew
Greenhorn

Joined: Aug 22, 2013
Posts: 1
Hi,

Does anyone know how to view all the members of a local group like 'Remote Desktop Users' and also add some members to the the group using java com? I tried some java code which was able to connect to the server but was not able to retrieve the member list. I am getting the error 'com.jacob.com.ComFailException: Can't map name to dispid: InstancesOf'. Please help guys.



public static void connectMachine()
{
ActiveXComponent wmi = new ActiveXComponent("WbemScripting.SWbemLocator");

Variant variantParameters[] = new Variant[4];
variantParameters[0] = new Variant(IP);
variantParameters[1] = new Variant("root\\cimv2");
variantParameters[2] = new Variant(adminUserName);
variantParameters[3] = new Variant(AdminPassword);
ActiveXComponent axWMI;
try
{
Variant conRet = wmi.invoke("ConnectServer", variantParameters);
axWMI = new ActiveXComponent(conRet.toDispatch());
System.out.println("connected");
Variant instances = wmi.invoke("InstancesOf", "Win32_Group");
Enumeration<Variant> en = new EnumVariant(instances.getDispatch());
while (en.hasMoreElements())
{
ActiveXComponent bb = new ActiveXComponent(en.nextElement().getDispatch());
System.out.println(bb.getPropertyAsString("PartComponent"));
}
}
catch (ComFailException e)
{
System.out.println("failed");
e.printStackTrace();
axWMI = null;
}
if (axWMI == null)
System.out.println("null");
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: List all local group members and add members to the local group on a remote machine using JAVA COM
 
Similar Threads
JNDI Active Directory Search issue
Variant parameter in Locale settings
Microsoft.Outlook jacob-1.17-M2-x86.dll
if statement (using BlueJ) and equalsIgnoreCase
Formatting Word ducuments using Jacob