LDAP登录集成

MaxKey支持LDAP包括Active Directory。

注释默认数据库认证

打开文件maxkey/spring/maxkey-security.xml,首先注释默认数据库认证方式


<!-- Default Realm-->
<!-- realm use jdbc -->
<bean id="authenticationRealm" class="org.maxkey.authn.realm.jdbc.JdbcAuthenticationRealm">
	<constructor-arg ref="jdbcTemplate"/>
</bean>

LDAP支持


<!-- LDAP Realm -->
<bean id="authenticationRealm" class="org.maxkey.web.authentication.realm.ldap.LdapAuthenticationRealm">
	<constructor-arg ref="jdbcTemplate"/>
	<property name="ldapServers">
		<list>
			<bean id="ldapServer1" class="org.maxkey.web.authentication.realm.ldap.LdapServer">
				<property name="ldapUtils">
					<bean id="ldapUtils" class="org.maxkey.ldap.LdapUtils">
						<property name="providerUrl" value="ldap://localhost:389"></property>
						<property name="principal" value="cn=root"></property>
						<property name="credentials" value="rootroot"></property>
						<property name="baseDN" value="dc=connsec,dc=com"></property>
					</bean>
				</property>
				<property name="filterAttribute" value="uid"></property>
			</bean>	
		</list>
	</property>
</bean> 

Active Directory支持


<!-- Active Directory  Realm -->
<bean id="authenticationRealm" class="org.maxkey.web.authentication.realm.activedirectory.ActiveDirectoryAuthenticationRealm">
	<constructor-arg ref="jdbcTemplate"/>
	<property name="activeDirectoryServers">
		<list>
			<bean id="activeDirectory1" class="org.maxkey.web.authentication.realm.activedirectory.ActiveDirectoryServer">
				<property name="activeDirectoryUtils">
					<bean id="ldapUtils" class="org.maxkey.ldap.ActiveDirectoryUtils">
						<property name="providerUrl" value="ldap://localhost:389"></property>
						<property name="principal" value="cn=root"></property>
						<property name="credentials" value="rootroot"></property>
						<property name="domain" value="connsec"></property>
					</bean>
				</property>
			</bean>	
		</list>
	</property>
</bean>