简体   繁体   中英

Browse ADAM and retrieve values from C#

This is my current PowerShell code:

connect-QADService -service 'view.domain.com' -Credential 'MyDomain\\Administrator'

$AllVMs= ( get-QADObject -SearchRoot 'vdi.vmware.int/Servers' -type pae-VM -IncludedProperties ipHostNumber,pae-SIDString )

How it can be rewrited in C# (.net 3.5) ?

Code:

DirectoryEntry entry = new DirectoryEntry("LDAP://view.domain.com/OU=Servers,DC=vdi,DC=vmware,DC=int", "domain\\Administrator", "paSSw0rd");

DirectorySearcher ds = new DirectorySearcher(entry);
ds.SearchScope = SearchScope.Subtree;
ds.PropertiesToLoad.AddRange(new String[] { "pae-SIDString", "ipHostNumber" });

Works like a charm :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM