i using below approach query members large ad groups.
try { directoryentry entry = new directoryentry("ldap://cn=my distribution list,ou=distribution lists,dc=fabrikam,dc=com"); directorysearcher searcher = new directorysearcher(entry); searcher.filter = "(objectclass=*)"; uint rangestep = 1000; uint rangelow = 0; uint rangehigh = rangelow + (rangestep - 1); bool lastquery = false; bool quitloop = false; { string attributewithrange; if(!lastquery) { attributewithrange = string.format("member;range={0}-{1}", rangelow, rangehigh); } else { attributewithrange = string.format("member;range={0}-*", rangelow); } searcher.propertiestoload.clear(); searcher.propertiestoload.add(attributewithrange); searchresult results = searcher.findone(); foreach(string res in results.properties.propertynames) { system.diagnostics.debug.writeline(res.tostring()); } if(results.properties.contains(attributewithrange)) { foreach(object obj in results.properties[attributewithrange]) { console.writeline(obj.gettype()); if(obj.gettype().equals(typeof(system.string))) { } else if (obj.gettype().equals(typeof(system.int32))) { } console.writeline(obj.tostring()); } if(lastquery) { quitloop = true; } } else { lastquery = true; } if(!lastquery) { rangelow = rangehigh + 1; rangehigh = rangelow + (rangestep - 1); } } while(!quitloop); } catch(exception ex) { // handle exception ex. } here retrieve samaccountname of members along distinguishedname.also have groups contains cross domain members. please help.
to value of attribute typically need call directoryentry.properties[propertyname].value, e.g.
var x = results.properties["distinguishedname"].value for indexed values might required provide index properties[propertyname][x].value
if value not populated default in result, might need force load using directorysearcher.propertiestoload.add(propertyname);
Comments
Post a Comment