Return Multi-Valued Attributes?
i trying dump list of values on single attribute. isn't issue single-valued attributes. display fine.
$strfilter = "(&(cn=user)(objectcategory=user)(|(publicdelegates=*)(publicdelegatesbl=*)))" $objdomain = new-object system.directoryservices.directoryentry("ldap://cn=users,dc=contoso,dc=com") $objsearcher = new-object system.directoryservices.directorysearcher $objsearcher.searchroot = $objdomain $objsearcher.pagesize = 1000 $objsearcher.filter = $strfilter $objsearcher.searchscope = "subtree" $colproplist = "cn", "publicdelegates", "publicdelegatesbl" foreach ($i in $colproplist){$objsearcher.propertiestoload.add($i)} $colresults = $objsearcher.findall() foreach ($objresult in $colresults) {$objitem = $objresult.properties $objitem.cn $objitem.publicdelegates $objitem.publicdelegatesbl $writehost }
i'm not familiar attributes, multi-valued attributes retrieved arrays. can enumerate values in foreach. example:
$domain = new-object system.directoryservices.directoryentry
$searcher = new-object system.directoryservices.directorysearcher
$searcher.searchroot = $domain
$searcher.pagesize = 100
$searcher.searchscope = "subtree"
$name = read-host "enter pre-windows 2000 logon name of user"
$searcher.filter = "(samaccountname=$name)"
$searcher.propertiestoload.add("memberof") > $null
$results = $searcher.findall()
foreach ($result in $results)
{
$groups = $result.properties.item("memberof")
foreach ($group in $groups)
{
"member of group $group"
}
}
-----
i use .properties.item("attributename") name of attribute case insensitive. help?
richard mueller - mvp directory services
Windows Server > Windows PowerShell
Comments
Post a Comment