diff --git a/examples/ldap/ldap-app/src/main/webapp/WEB-INF/keycloak.json b/examples/ldap/ldap-app/src/main/webapp/WEB-INF/keycloak.json
new file mode 100644
index 0000000000..84e1129a88
--- /dev/null
+++ b/examples/ldap/ldap-app/src/main/webapp/WEB-INF/keycloak.json
@@ -0,0 +1,10 @@
+{
+ "realm" : "ldap-demo",
+ "resource" : "ldap-app",
+ "realm-public-key" : "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCrVrCuTtArbgaZzL1hvh0xtL5mc7o0NqPVnYXkLvgcwiC3BjLGw1tGEGoJaXDuSaRllobm53JBhjx33UNv+5z/UMG4kytBWxheNVKnL6GgqlNabMaFfPLPCF8kAgKnsi79NMo+n6KnSY8YeUmec/p2vjO2NjsSAVcWEQMVhJ31LwIDAQAB",
+ "auth-server-url": "/auth",
+ "ssl-required" : "external",
+ "credentials": {
+ "secret": "password"
+ }
+}
\ No newline at end of file
diff --git a/examples/ldap/ldap-app/src/main/webapp/WEB-INF/web.xml b/examples/ldap/ldap-app/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..e6ec7c8cba
--- /dev/null
+++ b/examples/ldap/ldap-app/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,37 @@
+
+
+
+ ldap-portal
+
+
+
+ LDAPApp
+ /*
+
+
+ ldap-user
+
+
+
+
+
+
+ KEYCLOAK
+ does-not-matter
+
+
+
+ ldap-user
+
+
\ No newline at end of file
diff --git a/examples/ldap/ldap-app/src/main/webapp/index.jsp b/examples/ldap/ldap-app/src/main/webapp/index.jsp
new file mode 100644
index 0000000000..f2bf4cb99e
--- /dev/null
+++ b/examples/ldap/ldap-app/src/main/webapp/index.jsp
@@ -0,0 +1,66 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1" %>
+<%@ page import="org.keycloak.constants.ServiceUrlConstants" %>
+<%@ page import="org.keycloak.util.KeycloakUriBuilder" %>
+<%@ page import="org.keycloak.KeycloakSecurityContext" %>
+<%@ page import="org.keycloak.representations.IDToken" %>
+<%@ page import="org.keycloak.representations.AccessToken" %>
+<%@ page import="org.keycloak.representations.AccessToken.Access" %>
+<%@ page import="java.util.Map" %>
+<%@ page session="false" %>
+
+
+
+
+ LDAP Example
+
+
+ LDAP Example
+
+
+<%
+ String logoutUri = KeycloakUriBuilder.fromUri("/auth").path(ServiceUrlConstants.TOKEN_SERVICE_LOGOUT_PATH)
+ .queryParam("redirect_uri", "/ldap-portal").build("ldap-demo").toString();
+
+ KeycloakSecurityContext securityContext = (KeycloakSecurityContext) request.getAttribute(KeycloakSecurityContext.class.getName());
+ IDToken idToken = securityContext.getIdToken();
+ AccessToken accessToken = securityContext.getToken();
+%>
+ Logout
+
+
+
+ ID Token - basic claims
+ Username: <%=idToken.getPreferredUsername()%>
+ Email: <%=idToken.getEmail()%>
+ Full Name: <%=idToken.getName()%>
+ First: <%=idToken.getGivenName()%>
+ Last: <%=idToken.getFamilyName()%>
+
+
+
+ ID Token - other claims
+<%
+ for (Map.Entry claim : idToken.getOtherClaims().entrySet()) {
+%>
+ <%= claim.getKey() %>: <%= claim.getValue().toString() %>
+<%
+ }
+%>
+
+
+
+ Access Token - roles
+ Realm roles: <%= accessToken.getRealmAccess().getRoles().toString() %>
+<%
+ for (Map.Entry acc : accessToken.getResourceAccess().entrySet()) {
+%>
+ Resource: <%= acc.getKey() %>, Roles: <%= acc.getValue().getRoles().toString() %>
+<%
+ }
+%>
+
+
+
+
\ No newline at end of file
diff --git a/examples/ldap/ldap-app/users.ldif b/examples/ldap/ldap-app/users.ldif
index e69de29bb2..520d477e1a 100644
--- a/examples/ldap/ldap-app/users.ldif
+++ b/examples/ldap/ldap-app/users.ldif
@@ -0,0 +1,67 @@
+dn: dc=keycloak,dc=org
+objectclass: dcObject
+objectclass: organization
+o: Keycloak
+dc: Keycloak
+
+dn: ou=People,dc=keycloak,dc=org
+objectclass: top
+objectclass: organizationalUnit
+ou: People
+
+dn: ou=RealmRoles,dc=keycloak,dc=org
+objectclass: top
+objectclass: organizationalUnit
+ou: RealmRoles
+
+dn: ou=FinanceRoles,dc=keycloak,dc=org
+objectclass: top
+objectclass: organizationalUnit
+ou: FinanceRoles
+
+dn: uid=jbrown,ou=People,dc=keycloak,dc=org
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: jbrown
+cn: James
+sn: Brown
+mail: jbrown@keycloak.org
+postalCode: 88441
+userPassword: password
+
+dn: uid=bwilson,ou=People,dc=keycloak,dc=org
+objectclass: top
+objectclass: person
+objectclass: organizationalPerson
+objectclass: inetOrgPerson
+uid: bwilson
+cn: Bruce
+sn: Wilson
+mail: bwilson@keycloak.org
+postalCode: 88441
+postalCode: 77332
+postalCode: 66221
+street: Elm 5
+userPassword: password
+
+dn: cn=ldap-user,ou=RealmRoles,dc=keycloak,dc=org
+objectclass: top
+objectclass: groupOfNames
+cn: ldap-user
+member: uid=jbrown,ou=People,dc=keycloak,dc=org
+member: uid=bwilson,ou=People,dc=keycloak,dc=org
+
+dn: cn=ldap-admin,ou=RealmRoles,dc=keycloak,dc=org
+objectclass: top
+objectclass: groupOfNames
+cn: ldap-admin
+member: uid=jbrown,ou=People,dc=keycloak,dc=org
+
+dn: cn=accountant,ou=FinanceRoles,dc=keycloak,dc=org
+objectclass: top
+objectclass: groupOfNames
+cn: accountant
+member: uid=bwilson,ou=People,dc=keycloak,dc=org
+
diff --git a/misc/Testsuite.md b/misc/Testsuite.md
index ebaee4bfce..41a578cd25 100644
--- a/misc/Testsuite.md
+++ b/misc/Testsuite.md
@@ -94,11 +94,10 @@ To start a ApacheDS based LDAP server for testing LDAP sending run:
mvn exec:java -Pldap
-There are additional system properties you can use to configure (See EmbeddedServersFactory class for details). Once done, you can create LDAP Federation provider
+There are additional system properties you can use to configure (See LDAPEmbeddedServer class for details). Once done, you can create LDAP Federation provider
in Keycloak admin console with the settings like:
* Vendor: Other
* Connection URL: ldap://localhost:10389
-* Base DN: dc=keycloak,dc=org
* User DN Suffix: ou=People,dc=keycloak,dc=org
* Bind DN: uid=admin,ou=system
* Bind credential: secret
@@ -110,18 +109,18 @@ To start a ApacheDS based Kerberos server for testing Kerberos + LDAP sending ru
mvn exec:java -Pkerberos
-There are additional system properties you can use to configure (See EmbeddedServersFactory class for details) but for testing purposes default values should be good.
-By default ApacheDS LDAP server will be running on localhost:10389 and Kerberos KDC on localhost:6088 . LDAP will import initial data from [src/main/resources/kerberos/users-kerberos.ldif](src/main/resources/kerberos/users-kerberos.ldif) .
+There are additional system properties you can use to configure (See LDAPEmbeddedServer and KerberosEmbeddedServer class for details) but for testing purposes default values should be good.
+By default ApacheDS LDAP server will be running on localhost:10389 and Kerberos KDC on localhost:6088 .
Once kerberos is running, you can create LDAP Federation provider in Keycloak admin console with same settings like mentioned in previous LDAP section.
But additionally you can enable Kerberos authentication in LDAP provider with the settings like:
* Kerberos realm: KEYCLOAK.ORG
* Server Principal: HTTP/localhost@KEYCLOAK.ORG
-* KeyTab: $KEYCLOAK_SOURCES/testsuite/integration/src/main/resources/kerberos/http.keytab (Replace $KEYCLOAK_SOURCES with correct absolute path of your sources)
+* KeyTab: $KEYCLOAK_SOURCES/testsuite/integration/src/test/resources/kerberos/http.keytab (Replace $KEYCLOAK_SOURCES with correct absolute path of your sources)
Once you do this, you should also ensure that your Kerberos client configuration file is properly configured with KEYCLOAK.ORG domain.
-See [src/main/resources/kerberos/test-krb5.conf](src/main/resources/kerberos/test-krb5.conf) for inspiration. The location of Kerberos configuration file
+See [../testsuite/integration/src/test/resources/kerberos/test-krb5.conf](../testsuite/integration/src/test/resources/kerberos/test-krb5.conf) for inspiration. The location of Kerberos configuration file
is platform dependent (In linux it's file `/etc/krb5.conf` )
Then you need to configure your browser to allow SPNEGO/Kerberos login from `localhost` .
diff --git a/util/embedded-ldap/src/main/resources/ldap/default-users.ldif b/util/embedded-ldap/src/main/resources/ldap/default-users.ldif
index 4d6d87ee0c..ac3ffcb099 100644
--- a/util/embedded-ldap/src/main/resources/ldap/default-users.ldif
+++ b/util/embedded-ldap/src/main/resources/ldap/default-users.ldif
@@ -45,3 +45,22 @@ postalCode: 88441
postalCode: 77332
street: Elm 5
userPassword: password
+
+dn: cn=ldap-user,ou=RealmRoles,dc=keycloak,dc=org
+objectclass: top
+objectclass: groupOfNames
+cn: ldap-user
+member: uid=jbrown,ou=People,dc=keycloak,dc=org
+member: uid=bwilson,ou=People,dc=keycloak,dc=org
+
+dn: cn=ldap-admin,ou=RealmRoles,dc=keycloak,dc=org
+objectclass: top
+objectclass: groupOfNames
+cn: ldap-admin
+member: uid=jbrown,ou=People,dc=keycloak,dc=org
+
+dn: cn=accountant,ou=FinanceRoles,dc=keycloak,dc=org
+objectclass: top
+objectclass: groupOfNames
+cn: accountant
+member: uid=bwilson,ou=People,dc=keycloak,dc=org