Ambiguous Name Resolution (anr=*ma*) equivalent in .NET 3.5 DirectoryServices.AccountManagement


Out with the old and in with the new(er). I am shelving an old vb.net asp.net 2.0 "asmx" service in favor of a shiny new c#.net asp.net 4.0 WCF service.

My old service used System.DirectoryServices.DirectorySearcher with an anr= filter to good effect and allowed for a Google style search for user objects from a <em>single</em> input field.

I would really like to take advantage of 3.5's System.DirectoryServices.AccountManagement but have only been able to find variations of Microsoft's "Query by Example":

UserPrincipal u = new UserPrincipal(ctx); u.GivenName = "Jim"; u.Surname = "Daly"; PrincipalSearcher ps = new PrincipalSearcher(); ps.QueryFilter = u; PrincipalSearchResult<Principal> results = ps.FindAll();

My question is, do I have to dust off my DirectorySearcher code for anr type searches or am I missing some obvious ambiguous search capabilities in the AccountManagement namespace?

Many Thanks.



You might be able to write your own implementation of UserPrincipal that exposes a custom property:

[DirectoryObjectClass("user")] [DirectoryRdnPrefix("CN")] public class CustomUserPrincipal : UserPrincipal { public CustomUserPrincipal ( PrincipalContext context ) : base ( context ) { } [DirectoryProperty("anr")] public string Anr { get { return (string)ExtensionGet ( "anr" )[0]; } set { ExtensionSet ( "anr", value ); } } }


var u = new CustomUserPrincipal(ctx) { Anr = "*mr*" }; var ps = new PrincipalSearcher() { QueryFilter = u }; var results = ps.FindAll();


  • System.DirectoryServices.AccountManagement.PrincipalContext and Impersonation in a WCF service
  • Optimize AD search - get group members
  • Error on publishing: System.DirectoryServices.DirectoryServicesCOMException
  • Cross Domain Authentication using DirectoryServices
  • Insert Pandas dataframe into Cassandra Table
  • How to not need user input for install.packages(type = “both”)
  • Concise regex extract function in XSLT 2.0
  • How can I stop my python script when another python script is running?
  • FTPWebRequest .NET 3.5 vs 4
  • how to display   in Mozilla using XSL.
  • Does the MySQL IN clause execute the subquery multiple times?
  • Do query loads all the data in memory
  • Find group of records that match multiple values
  • Date Conversion from yyyy-mm-dd to dd-mm-yyyy
  • Debug.DrawLine not showing in the GameView
  • How do I alternate colors in Flat List (React Native)
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • Google Custom Search with transparent background
  • CSS Linear-gradient formatting issue accross different browsers
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Insert into database using onclick function
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Retrieving value from sql ExecuteScalar()
  • What is Eclipse's Declaration View used for?
  • Can I make an Android app that runs a web view in Chrome 39?
  • Redux, normalised entities and lodash merge
  • When should I choose bucket sort over other sorting algorithms?
  • what is the difference between the asp.net mvc application and asp.net web application
  • jquery mobile loadPage not working
  • Do create extension work in single-user mode in postgres?
  • Unanticipated behavior
  • Matrix multiplication with MKL
  • KeystoneJS: Relationships in Admin UI not updating
  • Hits per day in Google Big Query
  • Authorize attributes not working in MVC 4
  • Checking variable from a different class in C#
  • Busy indicator not showing up in wpf window [duplicate]
  • Binding checkboxes to object values in AngularJs
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF