Forum Stats

  • 3,855,433 Users
  • 2,264,502 Discussions


How to get the username/password of the current owner of the running code

680524 Member Posts: 43
edited Oct 10, 2011 7:04AM in Kerberos & Java GSS (JGSS)
Dear friends,

Our product is running on the App Server(weblogic/websphere...) and we also use security provider(OpenLDAP) and kerberos to support SSO. Before, when a user tyies to login in the first time, the way we use to authenticate the user is:
1) Accept the username/password
2) Query the security provider(OpenLDAP) to get the principles.
3) verity if the username/password is corrent or not.

As we know, to query the principles, we need to provide a search user(both username and password) if we configured the access control of the ldap server:
I have configured my envirioment as follows
1) In the LDAP server, configured the Middle Tire user(The Operating System user running the App Server) to have the permission to query principles.
2) The server is configured to runing on SSO envirioment.

My question is could I get the username/password of the OS user running the App Server at runtime so that I can query the ldap server without explicitly providing the search user?


Edited by: Ricky Ru on Oct 9, 2011 1:50 AM


  • EJP
    EJP Member Posts: 32,920 Gold Crown
    You can almost certainly not get the password, and if you can it is a sure sign that the system you are using is insecure. The way to verify the password with an LDAP server is to attempt an 'LDAP bind' as that user. In JNDI terms that means setting the authentication principal and credentials as environment properties of the context and attempting context.reconnect().
  • 680524
    680524 Member Posts: 43
    I might not describe clearly. The puspose is that in SSO enviroment, we want to use the Middle Tire Credential to search the principles from ldap server which is configured to allowed that. The question is that how to use the Middle Tire Credential at runtime. Could you specify your thoughts? Thanks.
  • EJP
    EJP Member Posts: 32,920 Gold Crown
    My thoughts are exactly the same. Unless you configure LDAP with plaintext passwords, which is strongly deprecated on security grounds, you can't get the user's password, because it is hashed, one way or another. So you have to do what I said. If this is for SSO you have to organize all the SSO subsystems to rely on the same LDAP authentication.
  • 680524
    680524 Member Posts: 43
    Thanks EJP.

    I have made some progress on this. But I have met another issue.
    *1) Using JAAS to login.*
    Subject subject = loginContext.getSubject();
    ldapContext = (LdapContext) Subject.doAs(subject, this);
    *2) Init the ldapContext to use the GSSAPI authentication*
    // this is called automatically by login()
    public Object run() {
    Hashtable ldapEnv = new Hashtable();
    ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    ldapEnv.put(Context.PROVIDER_URL, "ldap://");

    //System.setProperty("", "false");
    // This tells the GSS-API to use the cached ticket as
    // credentials, if it is available
    System.setProperty("", "false");
    try {
    InitialLdapContext ctx = new InitialLdapContext(ldapEnv,null);

    But I got the following exception when excuting new InitialLdapContext(ldapEnv,null);

    Debug is true storeKey false useTicketCache true useKeyTab false doNotPrompt false ticketCache is null isInitiator true KeyTab is null refreshKrb5Config is false principal is null tryFirstPass is false useFirstPass is false storePass is false clearPass is false
    Acquire TGT from Cache
    Principal is [email protected]
    Commit Succeeded

    javax.naming.AuthenticationException: GSSAPI [Root exception is GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Integrity check on decrypted field failed (31))]]
    at com.sun.jndi.ldap.sasl.LdapSasl.saslBind(
    at com.sun.jndi.ldap.LdapClient.authenticate(
    at com.sun.jndi.ldap.LdapCtx.connect(
    at com.sun.jndi.ldap.LdapCtx.<init>(
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(
    at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(
    at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(
    at javax.naming.spi.NamingManager.getInitialContext(
    at javax.naming.InitialContext.getDefaultInitCtx(
    at javax.naming.InitialContext.init(
    at javax.naming.ldap.InitialLdapContext.<init>(
    at Method)
    at LDAPKerbService.login(
    at LDAPKerbService.main(
    Caused by: GSS initiate failed [Caused by GSSException: No valid credentials provided (Mechanism level: Integrity check on decrypted field failed (31))]
    at com.sun.jndi.ldap.sasl.LdapSasl.saslBind(
    ... 16 more
    Caused by: GSSException: No valid credentials provided (Mechanism level: Integrity check on decrypted field failed (31))
    ... 17 more
    Caused by: KrbException: Integrity check on decrypted field failed (31)
    ... 20 more
    Caused by: KrbException: Identifier doesn't match expected value (906)
    ... 25 more

    Do you have any clue on this? Thanks.
This discussion has been closed.