T
Ty Moffett
I have a vbscript that will pull and print NT 4.0 domain
machine accounts. I am trying to find a way to do this
in C#.
We are NOT using active directory. We have one NT 4.0
domain.
My vbscript code is as follows:
--CODE--
set comps = getobject("WinNT://TULSA")
comps.filter = Array("Computer")
for each comp in comps
wscript.echo comp.name
next
--END CODE--
My C# code is as follows:
--CODE--
static void Main(string[] args)
{
DirectoryEntry myEntry = new DirectoryEntry
("WinNT://MYDOMAINHERE");
DirectorySearcher mySearcher = new
DirectorySearcher(myEntry);
Console.WriteLine(mySearcher.FindAll());
}
--END CODE--
It throws an exception on the FindAll() method.
--EXCEPTION DETAILS--
System.NotSupportedException was unhandled
Message="The provider does not support searching and
cannot search WinNT://MYDOMAINHERE."
Source="System.DirectoryServices"
StackTrace:
at
System.DirectoryServices.DirectorySearcher.FindAll
(Boolean findMoreThanOne)
at
System.DirectoryServices.DirectorySearcher.FindAll()
at test.Program.Main(String[] args) in
C:\Documents and Settings\tmoffett\my documents\visual
studio 2005\Projects\test\test\Program.cs:line 15
at System.AppDomain.nExecuteAssembly(Assembly
assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String
assemblyFile, Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAss
embly()
at
System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
at System.Threading.ExecutionContext.Run
(ExecutionContext executionContext, ContextCallback
callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
--END EXCEPTION DETAILS--
I substituted my actual domain name for "MYDOMAINHERE".
Is there a way to get a list of the machine accounts in
an NT 4.0 domain with C# and .NET?
Thanks.
machine accounts. I am trying to find a way to do this
in C#.
We are NOT using active directory. We have one NT 4.0
domain.
My vbscript code is as follows:
--CODE--
set comps = getobject("WinNT://TULSA")
comps.filter = Array("Computer")
for each comp in comps
wscript.echo comp.name
next
--END CODE--
My C# code is as follows:
--CODE--
static void Main(string[] args)
{
DirectoryEntry myEntry = new DirectoryEntry
("WinNT://MYDOMAINHERE");
DirectorySearcher mySearcher = new
DirectorySearcher(myEntry);
Console.WriteLine(mySearcher.FindAll());
}
--END CODE--
It throws an exception on the FindAll() method.
--EXCEPTION DETAILS--
System.NotSupportedException was unhandled
Message="The provider does not support searching and
cannot search WinNT://MYDOMAINHERE."
Source="System.DirectoryServices"
StackTrace:
at
System.DirectoryServices.DirectorySearcher.FindAll
(Boolean findMoreThanOne)
at
System.DirectoryServices.DirectorySearcher.FindAll()
at test.Program.Main(String[] args) in
C:\Documents and Settings\tmoffett\my documents\visual
studio 2005\Projects\test\test\Program.cs:line 15
at System.AppDomain.nExecuteAssembly(Assembly
assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String
assemblyFile, Evidence assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAss
embly()
at
System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
at System.Threading.ExecutionContext.Run
(ExecutionContext executionContext, ContextCallback
callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
--END EXCEPTION DETAILS--
I substituted my actual domain name for "MYDOMAINHERE".
Is there a way to get a list of the machine accounts in
an NT 4.0 domain with C# and .NET?
Thanks.