LDAP query in python

While the accepted answer does in fact show a proper way to bind to an LDAP server I do feel it didn’t answer the question holistically. Here is what I ended up implementing to grab the mail and department of a user. This somewhat blends the required attributes from the original question. l = ldap.initialize(‘ldap://ldap.myserver.com:389’) … Read more

How to connect with Java into Active Directory

Here is a simple code that authenticate and make an LDAP search usin JNDI on a W2K3 : class TestAD { static DirContext ldapContext; public static void main (String[] args) throws NamingException { try { System.out.println(“Début du test Active Directory”); Hashtable<String, String> ldapEnv = new Hashtable<String, String>(11); ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY, “com.sun.jndi.ldap.LdapCtxFactory”); //ldapEnv.put(Context.PROVIDER_URL, “ldap://societe.fr:389”); ldapEnv.put(Context.PROVIDER_URL, “ldap://dom.fr:389”); ldapEnv.put(Context.SECURITY_AUTHENTICATION, “simple”); … Read more

How do you authenticate against an Active Directory server using Spring Security?

I had the same banging-my-head-against-the-wall experience you did, and ended up writing a custom authentication provider that does an LDAP query against the Active Directory server. So my security-related beans are: <beans:bean id=”contextSource” class=”org.springframework.security.ldap.DefaultSpringSecurityContextSource”> <beans:constructor-arg value=”ldap://hostname.queso.com:389/” /> </beans:bean> <beans:bean id=”ldapAuthenticationProvider” class=”org.queso.ad.service.authentication.LdapAuthenticationProvider”> <beans:property name=”authenticator” ref=”ldapAuthenticator” /> <custom-authentication-provider /> </beans:bean> <beans:bean id=”ldapAuthenticator” class=”org.queso.ad.service.authentication.LdapAuthenticatorImpl”> <beans:property name=”contextFactory” ref=”contextSource” /> … Read more