Various Scripts and Application Code Segments for .NET, VB, C#, C++, C, Java, JavaScript, HTML, Python, Perl, AutoIT, Batch, ASP Classic, Objective-C, Swift, Unreal Engine 4, Unity3D & others. Also contains numerous IT tidbits, procedures, and tricks including Technology Hacks on various platforms.
Saturday, September 11, 2010
Loading Computers from an AD OU into a C# List
This piece of code does as described: Loading Computers from an AD OU into a C# List. Often you want to put Computers into a List from a given OU, and have it recursively search through the depths of the tree. This code will let you search at the root to the various subordinate child OUs. This excerpt is from my S-Cubed Program. ("SCCM Sucks Shit!"). Screenshot above.
void loadLDAP(string OU)
{
try
{
Base = new DirectoryEntry("LDAP://" +
OU);
DirectorySearcher mySearcher = new DirectorySearcher(Base);
mySearcher.Filter = ("(objectClass=computer)");
foreach (SearchResult resEnt in mySearcher.FindAll())
{
lstMachines.Items.Add(
resEnt.GetDirectoryEntry().Name.ToString().
Substring(3));
}
}
catch (Exception ex)
{
ntyS3.ShowBalloonTip(5000,
AppTitle,
ex.Message,
ToolTipIcon.Error);
stsPWS.Text = "Can't contact Domain!";
}
}
Subscribe to:
Post Comments (Atom)
Generating "Always On Top" NSWindow in macOS across all detected displays
Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift Langues, you m...
-
In Unreal Engine 4 you will eventually need Linear Interpolation between two values to do something like ping pong between two float val...
-
Recently Possess () has been deprecated from UE4 , and when writing classes based on AAIController you have to use the function OnPossess ...
-
Often we intermingle C++ and Blueprints, and need for the two to communicate. With Behavior Trees, using ENUMs is an everyday occurrence an...
No comments:
Post a Comment