LDAP Java authentication on windows

0

I would like to know how to get user login name with ldap in java, follow my code

public class ConexaoLDAOP {

    public static void main(String[] args) throws NamingException {

        String nome = "cn=Fulano,OU=USUARIOS,OU=TI,OU=Epasa,DC=EPASA,DC=local";

        Hashtable <String, String> env = new Hashtable <>();
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");

        env.put(Context.PROVIDER_URL, "ldap://localhost");
        env.put(Context.SECURITY_AUTHENTICATION, "simple");
        env.put(Context.SECURITY_PRINCIPAL, nome);
        env.put(Context.SECURITY_CREDENTIALS, "senha");

        try {
            new InitialDirContext(env).close();
             System.out.println("Usuario windowns conectado");
        } catch (AuthenticationException ex) {
            System.out.println("Credenciaais não conferem");;
        }

    }

}  

It turns out that so I can access !!. I want to get the login name that I enter into the PC and not the PC user name that are different example:

My PC has the name of So-and-so that shows in the start menu of Windowns, but what I do is another login.

    
asked by anonymous 13.07.2018 / 16:54

0 answers