I am having problem with ldap on spring, I know what that error means but idk what i am doing wrong in the config of the connection
this is my application.properties :
spring.ldap.urls=ldap://***
spring.ldap.base=OU=Account,DC=company,DC=lan
spring.ldap.username=CN=Intranet company
spring.ldap.password=pswd
The password are good and username too but maybe my base is false? can anyone help me plz?
and here is what i try to do
@Autowired
private LdapTemplate ldapTemplate;
System.out.println( ldapTemplate.search(
"OU=Account,DC=company,DC=lan",
"cn=" account.username ,
(AttributesMapper<String>) attrs -> (String) attrs.get("sAMAccountName").get()));
I just try to connect to the active directory and discover how it works
CodePudding user response:
The error message makes it clear that you're using Active Directory. So I'm pretty sure this is the problem:
spring.ldap.username=CN=Intranet company
I don't think Active Directory likes that format for the username. It either has to be:
- The full DN (
CN=Intranet company,OU=Account,DC=company,DC=lan), or - The plain username (
sAMAccountNameattribute), or DOMAIN\usernameif the user is not on the domain you're connecting to, or- The
userPrincipalName(e.g.[email protected]).
