返回信息流RT
包中有NamingEnumeration<SearchResult> search(Name name,
String filter,
SearchControls cons)
throws NamingException
这个方法,其中filter的格式在RFC 2254中有所规定
RFC 2254:http://www.ietf.org/rfc/rfc2254.txt
4. String Search Filter Definition
The string representation of an LDAP search filter is defined by the
following grammar, following the ABNF notation defined in [5]. The
filter format uses a prefix notation.
filter = "(" filtercomp ")"
filtercomp = and / or / not / item
and = "&" filterlist
or = "|" filterlist
not = "!" filter
filterlist = 1*filter
item = simple / present / substring / extensible
simple = attr filtertype value
filtertype = equal / approx / greater / less
equal = "="
approx = "~="
greater = ">="
less = "<="
extensible = attr [":dn"] [":" matchingrule] ":=" value
/ [":dn"] ":" matchingrule ":=" value
present = attr "=*"
substring = attr "=" [initial] any [final]
initial = value
any = "*" *(value "*")
final = value
attr = AttributeDescription from Section 4.1.5 of [1]
matchingrule = MatchingRuleId from Section 4.1.9 of [1]
value = AttributeValue from Section 4.1.6 of [1]
The attr, matchingrule, and value constructs are as described in the
corresponding section of [1] given above.
我没有太看懂这个,所以想问一下用过这个包的同学,filter中能使用正则表达式么?如果能的话怎么去使用?
这是一条镜像帖。来源:北邮人论坛 / java / #16909同步于 2010/12/16
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Java机器人发帖
有没有用过javax.naming.directory包的同学
tt82238971
2010/12/16镜像同步3 回复
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
【 在 irican 的大作中提到: 】
: filter不是正则表达式,而是LDAP的查询语句。sql与数据库的关系,和filter与ldap的关系类似。直接网上找例子吧,这个定义不太好理解。
: --
filter我明白不是正则表达式
我只是想知道filter支持模糊查找不,就像这样
filter = "o=JNDITutorial" 这是一个正确的filter
但如果我不知道“JNDITutorial”这个单词的全部,我只知道这个单词的前面是"JNDI"
有没有办法实现通过filter = "o=JNDI%"去达到找出"o=JNDITutorial" 的效果?
OK,搞定了
http://www.javaeye.com/topic/167125
这里面讲得相当详细
=======================
谢谢irican的回复