daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Oct 22nd, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// <summary>
  2.         /// Finds users whose properties have certain values.
  3.         /// </summary>
  4.         /// <param name="propValues">Properties and values to look for.</param>
  5.         /// <param name="props">Properties that will be requested by the engine from the returned users.</param>
  6.         /// <returns>Enumerable with users whose properties match.</returns>
  7.         public IEnumerable<IPrincipal> FindPrincipalsByPropertyValues(
  8.             IList<PropertyValue> propValues,
  9.             IList<PropertyName> props)
  10.         {
  11.             var user = new UserPrincipal(Context.GetPrincipalContext());
  12.             user.Name = "*";
  13.             foreach (PropertyValue v in propValues)
  14.             {
  15.                 if (v.QualifiedName == PropertyName.DISPLAYNAME)
  16.                 {
  17.                     user.Name = "*" + v.Value + "*";
  18.                 }
  19.             }
  20.            
  21.             var searcher = new PrincipalSearcher(user);
  22.             return searcher.FindAll().Select(u => new User((UserPrincipal)u, Context)).Cast<IPrincipal>();
  23.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top