模糊名称解析(ANR = *马*)在.NET 3.5 DirectoryServices.AccountManagement相当于 [英] Ambiguous Name Resolution (anr=*ma*) equivalent in .NET 3.5 DirectoryServices.AccountManagement
问题描述
出与旧和在与新的(ER)。 我搁置的老vb.net asp.net 2.0ASMX服务支持一个全新的C#.net asp.net 4.0 WCF服务的。
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.
我的旧服务使用System.DirectoryServices.DirectorySearcher与ANR =滤波效果好,并允许为谷歌风格的搜索用户对象从的单的输入字段。
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 single input field.
我真的想利用3.5的System.DirectoryServices.AccountManagement但只能够找到微软的通过实例查询的变化:
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();
我的问题是,我必须重温我DirectorySearcher从$ C $下ANR类型的搜索还是我失去了AccountManagement命名空间中一些明显的暧昧搜索功能?
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?
非常感谢。
学家
推荐答案
您也许可以写自己的实现UserPrincipal的暴露自定义属性:
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();
这篇关于模糊名称解析(ANR = *马*)在.NET 3.5 DirectoryServices.AccountManagement相当于的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!