在server.xml里增加realm定义,例如:
<Realm className="org.apache.catalina.realm.JNDIRealm" debug="99"
connectionURL="ldap://10.200.146.12:389"
userBase="dc=qmcc,dc=net"
userSearch="(uid={0})"
userSubtree="true"
roleBase="dc=qmcc,dc=net"
roleName="cn"
roleSubtree="true"
roleSearch="uniqueMember={0}"
/>
Realm元素属性含义参考如下:
Attribute | Description |
---|---|
className | The fully qualified Java class name of this Realm implementation. You MUST specify the value " |
connectionName | The directory username to use when establishing a connection to the directory for LDAP search operations. If not specified an anonymous connection is made, which is often sufficient unless you specify the |
connectionPassword | The directory password to use when establishing a connection to the directory for LDAP search operations. If not specified an anonymous connection is made, which is often sufficient unless you specify the |
connectionURL | The connection URL to be passed to the JNDI driver when establishing a connection to the directory. |
contextFactory | The fully qualified Java class name of the JNDI context factory to be used for this connection. By default, the standard JNDI LDAP provider is used ( |
debug | The level of debugging detail logged by this Realm to the associated Logger. Higher numbers generate more detailed output. If not specified, the default debugging detail level is zero (0). |
digest | The digest algorithm to apply to the plaintext password offered by the user before comparing it with the value retrieved from the directory. Valid values are those accepted for the algorithm name by the |
roleBase | The base directory entry for performing role searches. If not specified, the top level element in the directory context will be used. |
roleName | The name of the attribute that contains role names in the directory entries found by a role search. In addition you can use the |
roleSearch | The LDAP filter expression used for performing role searches, following the syntax supported by the |
roleSubtree | Set to |
userBase | The base element for user searches performed using the |
userPassword | Name of the attribute in the user's entry containing the user's password. If you specify this value, JNDIRealm will bind to the directory using the values specified by |
userPattern | A pattern for the distinguished name (DN) of the user's directory entry, following the syntax supported by the |
userRoleName | The name of an attribute in the user's directory entry containing zero or more values for the names of roles assigned to this user. In addition you can use the |
userSearch | The LDAP filter expression to use when searching for a user's directory entry, with |
userSubtree | Set to |