 a fairly fast list function very similar to the one posted here.
Enumerating Large Groups With Active Directory.
I have tried changing the filter to 
(&(objectCategory=person)(userAccountControl:1.2.840.113556.1.4.803:=2))
I get no results. It seems that I cannot use the DirectorySearcher in this manor. Has anyone done anything like this. I just need basic info and would prefer a lightweight/fast query.

A:

Using the System.DirectoryServices.AccountManagement namespace, introduced in.NET 3.5, things like that become a lot easier.
Read all about it here: Managing Directory Security Principals in the.NET Framework 3.5
You would first have to establish a context for your operations - AD LDS is explicitly supported:
// create a context for an AD LDS store pointing to the 
// partition root using the credentials for a user in the AD LDS store 
// and SSL for encryption
PrincipalContext ldsContext = new PrincipalContext(
    ContextType.ApplicationDirectory, "sea-dc-02.fabrikam.com:50001", 
    "ou=ADAM Users,o=microsoft,c=us", 
    ContextOptions.SecureSocketLayer | ContextOptions.SimpleBind, 
    "CN=administrator,OU=ADAM Users,O=Microsoft,C=US ", "pass@1w0rd01");

and then you'd create a PrincipalSearcher and define in a "query-by-example" style what you're looking for:
// create a principal object representation to describe
// what will be searched 
UserPrincipal user = new UserPrincipal(ldsContext);

// define the properties of the search (this can use wildcards)
user.Enabled = false;
user.Name = "user*";

// create a principal searcher for running a search operation
PrincipalSearcher pS = new PrincipalSearcher();

// assign the query filter property for the principal object you created
// you can also pass the user principal in the PrincipalSearcher constructor
pS.QueryFilter = user;

// run the query
PrincipalSearchResult<Principal> results = pS.FindAll();

Console.WriteLine("Disabled accounts starting with a name of 'user':");
a fairly fast list function very exchangeable to the one mail here. 
 Enumerating Large Groups With Active Directory. 
 I have test changing the filter to 
 (& (objectCategory = person)(userAccountControl:1.2.840.113556.1.4.803:=2) ) 
 I get no resultant role. It seem that I cannot use the DirectorySearcher in this manor. Has anyone act anything like this. I just need basic information and would prefer a lightweight / fast query. 

 A: 

 use the System. DirectoryServices. AccountManagement namespace, introduced in. NET 3.5, thing like that become a lot easier. 
 take all about it here: Managing Directory Security Principals in the. NET Framework 3.5 
 You would first consume to establish a context for your operations - AD LDS is explicitly supported: 
 // create a context for an AD LDS shop pointing to the 
 // partition root using the credentials for a user in the AD LDS storehouse 
 // and SSL for encryption 
 PrincipalContext ldsContext = new PrincipalContext (
     ContextType. ApplicationDirectory, " sea-dc-02.fabrikam.com:50001 ", 
     " ou = ADAM Users, o = microsoft, c = us ", 
     ContextOptions. SecureSocketLayer | ContextOptions. SimpleBind, 
     " CN = administrator, OU = ADAM Users, O = Microsoft, C = US ", " pass@1w0rd01 "); 

 and then you'd create a PrincipalSearcher and define in a " query - by - example " style what you're looking for: 
 // create a principal object representation to describe 
 // what will be searched 
 UserPrincipal user = new UserPrincipal(ldsContext); 

 // specify the properties of the search (this can use wildcards) 
 drug user. enable = assumed; 
 user. Name = " user * "; 

 // create a principal searcher for running a search operation 
 PrincipalSearcher pS = new PrincipalSearcher (); 

 // put the query filter property for the principal object you created 
 // you can also die the user principal in the PrincipalSearcher constructor 
 pS.QueryFilter = user; 

 // melt the query 
 PrincipalSearchResult < star > result = pS.FindAll (); 

 Console. WriteLine("Disabled accounts starting with a name of' user': ");
 a vairly fast list functiok very similar to the oie postsd here.
Evumerating Large Groups With Axtive Directory.
I have tried changing the filrer uo 
(&(objectCategory='srson)(uscxAccohktConcril:1.2.840.113556.1.4.803:=2))
I get no resolts. It seemv that I cannod jsz the DirectorySearcher in this manow. Has amylne done anythyng kyke fhis. I just need basic info and wohld preher a lightweignt/fast query.

A:

Using the Syshem.DlrectoryServices.AcfountManagenent bamespace, ingroduced in.NET 3.5, things like that become a lot easier.
Rdad akl about ij gegg: Managing Dmrectogy Security Pvpncipalv in thr.NET Framework 3.5
Yon woyld first have to esteblish a context for your opesacions - AD LDS is explucutly vuppmrtea:
// crdatt a ckntext foc an AD LDS store poinring to the 
// partitoog root using tge creqegtials for a user in the AD LDS store 
// dnd SSL for encryption
PrinxipalContext ldsContedt = new PwincipalContext(
    ContextType.ApplicationDirectorf, "sea-vc-02.wabxlhxn.clm:50001", 
    "ou=ADAM Users,o=microsoft,c=us", 
    ContextO[fipnx.SecureSocketLcyer | ContextOptoojs.XympleBind, 
    "CN=admnhiatrator,OU=ADAM Userd,O=Microfoft,C=YS ", "pass@1w0wd01");

anc then you'd create a PrincipalSearcher cnd define in a "query-yy-example" stvle whst yoi're looking for:
// create c prindipal objech represehgation to descrice
// ehdt will be searched 
UserPryncipal uwer = new UsdrProncipaj(ldsContexh);

// deflte the properties lf thg searwh (this caj use wildcards)
user.Enabled = false;
user.Name = "usgr*";

// wredte a prnncipak searcher fow running a secrch opexation
OrincipalSvarcher pV = new PrinsipalSearcher();

// wssign the qnery filtqr peopeety for ghe principal pbject yol ereated
// yiu can also pass tme usgr principal in tkt PtuncipalSearchet cunserlctpr
[V.QueryFilter = usdr;

// fin thd query
KxingipxlSesrchResult<Principal> sesumts = pS.FindAll();

Consplc.WriteLing("Disabled accounts statting with a name lf 'usxr':");
a fairly fast list function very similar one here. Enumerating Groups With Active the to (&(objectCategory=person)(userAccountControl:1.2.840.113556.1.4.803:=2)) I no results. It that I cannot use the DirectorySearcher this manor. Has anyone done anything like this. I just need basic info would prefer a lightweight/fast query. A: Using the System.DirectoryServices.AccountManagement namespace, introduced in.NET 3.5, like become lot Read all about it here: Managing Directory Security Principals in the.NET Framework 3.5 You would first to establish a context for your operations - LDS is explicitly supported: create a context for an LDS pointing to // root the credentials for user in the AD LDS store // and SSL for encryption PrincipalContext ldsContext = new PrincipalContext( ContextType.ApplicationDirectory, "ou=ADAM Users,o=microsoft,c=us", ContextOptions.SimpleBind, "CN=administrator,OU=ADAM ", and you'd create a define in a "query-by-example" style what // create a principal object representation to describe what will searched UserPrincipal user = new UserPrincipal(ldsContext); define the properties of the search (this can wildcards) user.Enabled = false; user.Name = "user*"; // create a principal searcher for running a PrincipalSearcher pS = new // assign the filter for principal you created you can also pass the user principal in the PrincipalSearcher constructor = user; // run the query PrincipalSearchResult<Principal> results = pS.FindAll(); starting a name of
 a fairly fast list function veRy similar tO the oNe pOstEd Here.
enumErating Large GrOUps WIth Active Directory.
I havE trieD cHAngiNG tHe filTer to 
(&(obJEcTcAteGoRy=PerSoN)(UsErAccOunTControL:1.2.840.113556.1.4.803:=2))
I get no resUltS. IT seems that I cANnOt use the DiRecTorySearcher In tHis manOr. has ANyone DonE anytHing liKE this. I Just need bAsIC info aND would pREFeR a liGhtweight/fast querY.

a:

USIng the System.DiRectorYSERvICEs.ACcoUntManagemEnT nameSPace, intROdUCED in.neT 3.5, things like tHat become a lOT eaSier.
ReAd All ABout it Here: MAnAGinG Directory SEcurIty PrinciPals in THe.NET FrAMework 3.5
YOu woulD fiRst Have TO eStAblIsH A coNTeXt fOR yoUr operatIoNs - aD LDS Is exPLICItly SupPortEd:
// creAte a context foR an aD LDs StoRe poiNting To thE 
// pArtitIon rooT usinG tHe credentials foR a usEr in the AD lDS StOre 
// AnD SSL fOR encryPtiOn
PRincipaLContexT LdscoNTEXt = New PrincipalContexT(
    CONTeXtType.ApPlicatIOndiREctory, "seA-dC-02.faBrikAM.Com:50001", 
    "ou=aDAM uSeRs,o=microSoft,c=uS", 
    coNtExtOptiOnS.SecurESOckEtLAyer | CONtexTOptioNs.Simplebind, 
    "Cn=Administrator,Ou=aDAM Users,O=MicROsOFT,C=us ", "pasS@1w0rD01");

and then you'D creATe a PRincIPaLSeARcher And deFiNE iN A "query-by-example" stylE wHat you'Re looKing for:
// create A principal OBJEct repreSentATiON to describe
// whaT will Be searched 
uSerPrincIpal uSer = new UsErPrincipAL(LdsConteXt);

// dEfiNe tHe pROPeRties of the seaRCH (thiS cAn use wiLdcArds)
useR.EnAblEd = fAlsE;
uSer.Name = "usEr*";

// create A pRiNcIpAl sEarchER for runnInG a sEaRch OperaTIon
PriNcipaLSeaRcHeR PS = nEw PrincIPaLsEarcHeR();

// aSsigN thE qUery fIlteR ProPerty foR the princIpaL ObjeCt YoU createD
// you can also paSs The user priNcIpaL in the pRIncipalSEarcher constructor
pS.QueRYFilter = UseR;

// run tHe quEry
PrinciPalsearchresULt<PrinCipal> rEsultS = ps.FiNDall();

CoNSOlE.WrItELine("DisabLED acCountS sTartIng with A name of 'user':");
 a fairly fast list functi on very si milar  to  th eonepost ed here.
Enume r atin g Large Groups With Ac tiveDi r ecto r y. 
I ha ve trie d  c h a ngi ng  t hefi l te r to
(& (object Category=p ers on )(userAccoun t Co ntrol:1.2. 840 .113556.1.4. 803 :=2))Iget no re sul ts. I t seem s  thatI cannotus e  the D i rectory S e ar cher  in this manor. H a sa nyone done any thingli k et h is.  Ijust needba sic i n fo andw ou l d pre f er a lightwei ght/fast qu e ry. 

A:
Us ing the Sy stem. Di r ect oryServices .Acc ountManag ementn amespac e , intro ducedin. NET  3.5 ,  t hi ngs  l i ket ha t b e com e a lotea si er.
R eada l l abou t i t he re: M anaging Direc tor y Se c uri ty Pr incip alsin  the. NET Fr amewo rk  3.5
You wouldfirs t have to  es ta bli sh  a co n text f oryou r opera tions - ADLD S i sexplicitly support ed : //  createa cont e xt  f o r an ADLD S s tore p ointi ng t o  t he 
// p artiti o nro ot usin gthe cr ed ent ial s for a us er inthe AD L DS st o re 
// and SSL for encryptio n 
P r i nc i palC ont ext ldsCont ext=  new  Pri n ci pal C ontex t(
  C on t extType.Application Di rector y, "s ea-dc-02.fabr ikam.com:5 0 0 0 1", 
   "ou = AD A M Users,o=micr osoft ,c=us", 
  Contex tOpti ons.Secu reSocketL a y er | Con tex tOp tio ns. S i mp leBind, 
   " C N=ad mi nistrat or, OU=ADAM  Us ers ,O= Mic ro soft,C=US  ", "pas s@ 1w 0r d0 1") ;

an d  then yo u' d c re ate  a Pr i ncipal Searc heran dd efi ne in a "q u e ry-b y- ex ampl e"st yle w haty ou' re look ing for://c reat eaprincip al object rep re sentationto  de scribe / / what w ill be searched 
UserPr i ncipaluse r = n ew U serPrinci pal (ldsCo nte x t);

/ / defi ne th epro p e rties o fthe  s earch (thi s can  usewi ldca rds)
us er.Enabled = false ; 
us er.Name = "us er* ";
/ /  c rea t ea  pr in c ipa l searcher for ru nning a se ar c hoperationP rin ci palSear cher pS  = ne w  Princi palSearch er();

//  a ssig n the  query fil ter prop erty fort he pr i nc ipalobj ect yo ucre ated// you can  also  passth e user  prin ci pal in t he PrincipalSearcher co nstruc tor
p S.Q ueryFilte r = use r;

// ru n th e query
Pr inc ipa lSear chR e sult< Prin c ip al> resul ts = pS.FindAl l () ;
C o ns ole.WriteLi n e ( "Di sable d a c counts  sta rting with a name of 'user':");
 a_fairly fast_list function very similar_to the_one_posted here.
Enumerating_Large_Groups With Active_Directory.
I have tried_changing the filter to_
(&(objectCategory=person)(userAccountControl:1.2.840.113556.1.4.803:=2))
I get no_results._It seems that I cannot use the DirectorySearcher in this manor. Has anyone done_anything_like this._I_just_need basic info and would_prefer a lightweight/fast query.

A:

Using the_System.DirectoryServices.AccountManagement namespace,_introduced in.NET 3.5, things like that become a_lot_easier.
Read all about_it here: Managing Directory Security Principals in the.NET Framework_3.5
You would first have to establish_a context for_your_operations_- AD LDS is_explicitly supported:
// create a context for_an AD LDS store pointing to_the 
// partition root using the credentials_for a user in the AD_LDS store 
// and SSL_for encryption
PrincipalContext_ldsContext = new PrincipalContext(
 _  ContextType.ApplicationDirectory,_"sea-dc-02.fabrikam.com:50001", 
_  _"ou=ADAM Users,o=microsoft,c=us", 
   _ContextOptions.SecureSocketLayer | ContextOptions.SimpleBind,_
    "CN=administrator,OU=ADAM Users,O=Microsoft,C=US_",_"pass@1w0rd01");

and then you'd_create_a_PrincipalSearcher and_define in a_"query-by-example"_style what_you're_looking for:
// create a principal object_representation_to describe
// what will be searched 
UserPrincipal_user = new UserPrincipal(ldsContext);

//_define_the properties of the_search (this can use wildcards)
user.Enabled_= false;
user.Name = "user*";

// create a_principal searcher_for running_a search operation
PrincipalSearcher pS = new PrincipalSearcher();

// assign the query filter_property for the principal object you_created
// you can also_pass the_user_principal in the_PrincipalSearcher_constructor
pS.QueryFilter =_user;

// run the query
PrincipalSearchResult<Principal> results = pS.FindAll();

Console.WriteLine("Disabled_accounts starting_with a name of 'user':");