浏览ADAM并从C#中检索值

时间:2010-10-07 11:32:08

标签: c# powershell adam

这是我目前的PowerShell代码:

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

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

如何在C#(.net 3.5)中重新编写?

1 个答案:

答案 0 :(得分:0)

代码:

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" });

像魅力一样工作:)