Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Active Directory get active computers
#1
Do you know a qm way to get a list of all active computers of an active directory?

qm is running on the main server 2012 r2 server and i am admin.

a c# discussion i stumpled over
http://stackoverflow.com/questions/1605 ... -directory
pi
#2
Macro Get active directory computers
Code:
Copy      Help
ARRAY(str) a=CsFunc("")
out a


#ret
//C# code
using System;
using System.Collections.Generic;
using System.DirectoryServices;

public class Test
{
public static string[] GetComputers()
{
;;;;List<string> ComputerNames = new List<string>();

;;;;DirectoryEntry entry = new DirectoryEntry("LDAP://YourActiveDirectoryDomain.no");
;;;;DirectorySearcher mySearcher = new DirectorySearcher(entry);
;;;;mySearcher.Filter = ("(objectClass=computer)");
;;;;mySearcher.SizeLimit = int.MaxValue;
;;;;mySearcher.PageSize = int.MaxValue;

;;;;foreach(SearchResult resEnt in mySearcher.FindAll())
;;;;{
;;;;;;;;//"CN=SGSVG007DC"
;;;;;;;;string ComputerName = resEnt.GetDirectoryEntry().Name;
;;;;;;;;if (ComputerName.StartsWith("CN="))
;;;;;;;;;;;;ComputerName = ComputerName.Remove(0,"CN=".Length);
;;;;;;;;ComputerNames.Add(ComputerName);
;;;;}

;;;;mySearcher.Dispose();
;;;;entry.Dispose();

;;;;return ComputerNames.ToArray();
}
}


Forum Jump:


Users browsing this thread: 1 Guest(s)