Thursday, March 29, 2012

List Domain Computers

Hello,

I have a simple bit of code which I have found in the forums which lists all
the computer(s) in a domain.

The code is: DirectoryEntry domainEntry = new
DirectoryEntry("WinNT://DOMAIN");
domainEntry.Children.SchemaFilter.Add("computer");
foreach(DirectoryEntry server in domainEntry.Children)
computers.Add(server.Name);

(where computers is an ArrayList)
When executed from within a console application I get the expected results
however I want to show
the list in a drop down list on an asp.net page.

When I put the code in my asp.net page, the dropdown list box always remains
empty.
Is this a permissions problem? Any suggestion how I can remedy this problem
would be gratefully appreciated.

Regards
LloydHi,

I solved this by using Impersonation

"Lloyd Taylor" <lltaylor2000@.yahoo.com> wrote in message
news:%23BNVq7bkEHA.3340@.TK2MSFTNGP14.phx.gbl...
> Hello,
> I have a simple bit of code which I have found in the forums which lists
all
> the computer(s) in a domain.
> The code is: DirectoryEntry domainEntry = new
> DirectoryEntry("WinNT://DOMAIN");
> domainEntry.Children.SchemaFilter.Add("computer");
> foreach(DirectoryEntry server in domainEntry.Children)
> computers.Add(server.Name);
> (where computers is an ArrayList)
> When executed from within a console application I get the expected results
> however I want to show
> the list in a drop down list on an asp.net page.
> When I put the code in my asp.net page, the dropdown list box always
remains
> empty.
> Is this a permissions problem? Any suggestion how I can remedy this
problem
> would be gratefully appreciated.
> Regards
> Lloyd

0 comments:

Post a Comment