Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// Finds users whose properties have certain values.
- /// </summary>
- /// <param name="propValues">Properties and values to look for.</param>
- /// <param name="props">Properties that will be requested by the engine from the returned users.</param>
- /// <returns>Enumerable with users whose properties match.</returns>
- public IEnumerable<IPrincipal> FindPrincipalsByPropertyValues(
- IList<PropertyValue> propValues,
- IList<PropertyName> props)
- {
- var user = new UserPrincipal(Context.GetPrincipalContext());
- user.Name = "*";
- foreach (PropertyValue v in propValues)
- {
- if (v.QualifiedName == PropertyName.DISPLAYNAME)
- {
- user.Name = "*" + v.Value + "*";
- }
- }
- var searcher = new PrincipalSearcher(user);
- return searcher.FindAll().Select(u => new User((UserPrincipal)u, Context)).Cast<IPrincipal>();
- }
Add Comment
Please, Sign In to add comment