Active Directory Sample Errors

G

Guest

I'm going to need to get a list of users for an upcoming project and Active
Directory seems to be a good place to get it. I'm trying to get the
"Walkthrough: Viewing Local Directory Objects" example to work; but I keep
getting...

An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in system.directoryservices.dll

Additional information: Unspecified error

I've tried a few things and nothing I do seems to work. Does anyone know
what the problem might be?
 
W

Willy Denoyette [MVP]

Frank_00001 said:
I'm going to need to get a list of users for an upcoming project and
Active
Directory seems to be a good place to get it. I'm trying to get the
"Walkthrough: Viewing Local Directory Objects" example to work; but I keep
getting...

An unhandled exception of type
'System.Runtime.InteropServices.COMException'
occurred in system.directoryservices.dll

Additional information: Unspecified error

I've tried a few things and nothing I do seems to work. Does anyone know
what the problem might be?

Without seeing your code and the point that it fails? No.

Willy.
 
G

Guest

I followed the instructions from "Walkthrough: Viewing Local Directory
Objects" copying the source directly from there and replacing the domain with
my organization's domain and YourComputerName with my computer's name.

The spot where it errors is in Form1_Load at the foreach statement
specifically on the entryPC.Children

private void Form1_Load(object sender, System.EventArgs e)
{
TreeNode users = new TreeNode("Users");
TreeNode groups = new TreeNode("Groups");
TreeNode services = new TreeNode("Services");
viewPC.Nodes.AddRange(new TreeNode[] { users, groups, services });

foreach(System.DirectoryServices.DirectoryEntry child
in entryPC.Children)
{
TreeNode newNode = new TreeNode(child.Name);

switch (child.SchemaClassName)
{
case "User" :
users.Nodes.Add(newNode);
break;
case "Group" :
groups.Nodes.Add(newNode);
break;
case "Service" :
services.Nodes.Add(newNode);
break;
}
AddPathAndProperties(newNode, child);
}
}
 
W

Willy Denoyette [MVP]

This is only a part of the code 99% is windows forms code but the essential
parts are missing (where you create entryPC, please don't force us to go
through the walkthrough; create a small console application that illustrates
the problem and don't waste your time with walkthrough's.

Willy.

Frank_00001 said:
I followed the instructions from "Walkthrough: Viewing Local Directory
Objects" copying the source directly from there and replacing the domain
with
my organization's domain and YourComputerName with my computer's name.

The spot where it errors is in Form1_Load at the foreach statement
specifically on the entryPC.Children

private void Form1_Load(object sender, System.EventArgs e)
{
TreeNode users = new TreeNode("Users");
TreeNode groups = new TreeNode("Groups");
TreeNode services = new TreeNode("Services");
viewPC.Nodes.AddRange(new TreeNode[] { users, groups, services });

foreach(System.DirectoryServices.DirectoryEntry child
in entryPC.Children)
{
TreeNode newNode = new TreeNode(child.Name);

switch (child.SchemaClassName)
{
case "User" :
users.Nodes.Add(newNode);
break;
case "Group" :
groups.Nodes.Add(newNode);
break;
case "Service" :
services.Nodes.Add(newNode);
break;
}
AddPathAndProperties(newNode, child);
}
}

Willy Denoyette said:
Without seeing your code and the point that it fails? No.

Willy.
 
G

Guest

I seem to be having some success with "DirectorySearcher" instead of going
the route I was trying here.

Thanks Anyway

Willy Denoyette said:
This is only a part of the code 99% is windows forms code but the essential
parts are missing (where you create entryPC, please don't force us to go
through the walkthrough; create a small console application that illustrates
the problem and don't waste your time with walkthrough's.

Willy.

Frank_00001 said:
I followed the instructions from "Walkthrough: Viewing Local Directory
Objects" copying the source directly from there and replacing the domain
with
my organization's domain and YourComputerName with my computer's name.

The spot where it errors is in Form1_Load at the foreach statement
specifically on the entryPC.Children

private void Form1_Load(object sender, System.EventArgs e)
{
TreeNode users = new TreeNode("Users");
TreeNode groups = new TreeNode("Groups");
TreeNode services = new TreeNode("Services");
viewPC.Nodes.AddRange(new TreeNode[] { users, groups, services });

foreach(System.DirectoryServices.DirectoryEntry child
in entryPC.Children)
{
TreeNode newNode = new TreeNode(child.Name);

switch (child.SchemaClassName)
{
case "User" :
users.Nodes.Add(newNode);
break;
case "Group" :
groups.Nodes.Add(newNode);
break;
case "Service" :
services.Nodes.Add(newNode);
break;
}
AddPathAndProperties(newNode, child);
}
}

Willy Denoyette said:
I'm going to need to get a list of users for an upcoming project and
Active
Directory seems to be a good place to get it. I'm trying to get the
"Walkthrough: Viewing Local Directory Objects" example to work; but I
keep
getting...

An unhandled exception of type
'System.Runtime.InteropServices.COMException'
occurred in system.directoryservices.dll

Additional information: Unspecified error

I've tried a few things and nothing I do seems to work. Does anyone
know
what the problem might be?


Without seeing your code and the point that it fails? No.

Willy.
 

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