diff --git a/samples/javaconfig/ldap/src/main/java/org/springframework/security/samples/config/SecurityConfig.java b/samples/javaconfig/ldap/src/main/java/org/springframework/security/samples/config/SecurityConfig.java
index 116219d418..da5de6aa67 100644
--- a/samples/javaconfig/ldap/src/main/java/org/springframework/security/samples/config/SecurityConfig.java
+++ b/samples/javaconfig/ldap/src/main/java/org/springframework/security/samples/config/SecurityConfig.java
@@ -29,7 +29,8 @@ public class SecurityConfig {
auth
.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
- .groupSearchBase("ou=groups");
+ .groupSearchBase("ou=groups")
+ .contextSource().port(0);
}
// @formatter:on
-}
\ No newline at end of file
+}
diff --git a/samples/xml/ldap/src/main/webapp/WEB-INF/applicationContext-security.xml b/samples/xml/ldap/src/main/webapp/WEB-INF/applicationContext-security.xml
index 0369dd109e..1448f21d21 100644
--- a/samples/xml/ldap/src/main/webapp/WEB-INF/applicationContext-security.xml
+++ b/samples/xml/ldap/src/main/webapp/WEB-INF/applicationContext-security.xml
@@ -17,7 +17,7 @@
-
+