2 Replies Latest reply: Dec 18, 2012 11:02 AM by beachw08 RSS

    What's the best way to get a list of users from the embedded ldap?

    beachw08
      I have an ADF Fusion Web app, and I was just wondering what is the best way of retrieving a list of all users in the embedded ldap of the Weblogic server?
        • 1. Re: What's the best way to get a list of users from the embedded ldap?
          Puthanampatti
          http://docs.oracle.com/cd/E12840_01/wls/docs103/config_scripting/config_WLS.html
          • 2. Re: What's the best way to get a list of users from the embedded ldap?
            beachw08
            I used this instead, it was a lot easier.

            This is an introduction to the api. http://docs.oracle.com/cd/E12839_01/core.1111/e10043/devuserole.htm#BABBIGAJ

            And this is a link to the Api. http://docs.oracle.com/cd/E15523_01/apirefs.1111/e14658/toc.htm

            As for displaying a list of users all belonging to a certain group this is how, I did it.
                    
                    IdentityStoreFactoryBuilder builder = new 
                       IdentityStoreFactoryBuilder ();
                    
                    IdentityStoreFactory oidFactory;
                    Hashtable factEnv = new Hashtable();
                  
                    // Creating the factory instance
                    factEnv.put(OIDIdentityStoreFactory.ST_SECURITY_PRINCIPAL,
                       "<Put your ldap connection user name here>");//user name
                    factEnv.put(OIDIdentityStoreFactory.ST_SECURITY_CREDENTIALS,
                       "<put the ldap connection password here>");//password
                    factEnv.put(OIDIdentityStoreFactory.ST_LDAP_URL,
                       "ldap://server:port/");
                        
                    try {
                        oidFactory =
                                builder.getIdentityStoreFactory(
                       "oracle.security.idm.providers.wlsldap.WLSLDAPIdentityStoreFactory", factEnv); //This is for connecting to the embedded weblogic ldap
                        IdentityStore oidStore = oidFactory.getIdentityStoreInstance(factEnv);
                                  
                        Role role = null;
                        role = oidStore.searchRole(oidStore.SEARCH_BY_UNIQUE_NAME, 
                                                   "cn=California,ou=groups,ou=myrealm,dc=base_domain"); //used the unique name of my role, but your supposed to be able to just use the name but I could never get it to work.
                     
                                                                          
                        // Searching for users
                        SearchResponse resp = role.getRoleProfile().getGrantees(null, true);
                        System.out.println("Searched users are:");
                        while (resp.hasNext()) {
                           Identity idy = resp.next();
                           System.out.println("Unique name: "+idy.getUniqueName());
                       }
                    } catch (IMException ex) {
                        ex.printStackTrace();
                    }
                    
                   
                }
            }