I’m an Oracle ACE!

I have been chosen for the Oracle ACE award.I had accepted it.Now, I am an Oracle ACE!

rsz_o_acelogo_clr

I’m proud and humbled to be part of this group of technical Oracle experts, and hope to live up to their standards.This great title comes with great responsibilities.Now i am more responsible for add more knowledge to the community.I will try my level best to achieve this. I am 485th person who got this title.

Its a great learning experience for me as well.

Please check my Oracle ACE profile

ace

20141011_105342(0)

Keep looking for some interesting post in future.

Happy learning with Vinay Kumar in techartifact.

New updated OTN forums

Hi All,

Today, OTN is in new look.OTN has recently been updated .You will see really good User interface.Its based on JIVE 7 .
Few of recent changes here –

Updated Profiles

Profile pages have a new look and purpose. You can now add more photos, highlight featured content, and list your own skills and expertise for others to endorse. When viewing other people’s profiles, you can see their recent activity, their top (public) Places, and you can endorse them for skills.

Impact Metrics

More powerful than a “read receipt,” Impact Metrics give you personal analytics on content you’ve created. Beyond view counts, you can now see the impact of your content, reach of the message, sentiment and response. Depending on your community settings, you can see viewers by department plus view which users specifically have read or referred others to your content. Impact Metrics are available for documents, discussions, and blog posts. Content created after your upgrade will show metrics immediately, while content created before the upgrade will show metrics only after your network data has been completely migrated.

Changes i like

Blog post– You can directly create an blog article in OTN from your profile.Now anyone can writes blogs directly on OTN.
Upload document- You can share picture, documents etc in forum with features of restricted viewing as well.
Create an Idea –
Create an Poll

and lot of changes. Make sure you update ur profile.Enjoy new look of OTN

1

Happy learning with Vinay and OTN

Make your ldap search fast

Problem- I am using JNDI to connect to ldap active directory, and i want to search for users with the name contains the search string,. Its very slow.
my search method is as follows:

public static List<LDAPUser> searchContactsByName(
        ExtendedDirContext extendedDirContext, String name) {

    try {

        LdapContext ldapContext = extendedDirContext.getLdapContext();
        String searchBaseStr = extendedDirContext.getSearchBase();

        String sortKey = LDAPAttributes.NAME;
        ldapContext.setRequestControls(new Control[] { new SortControl(
                sortKey, Control.CRITICAL) });

        SearchControls searchCtls = new SearchControls();
        searchCtls.setTimeLimit(1000 * 10);

        String returnedAtts[] = { LDAPAttributes.USER_NAME,
                LDAPAttributes.NAME };
        searchCtls.setReturningAttributes(returnedAtts);

        searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);

        String searchFilter = "(&(ObjectCategory=person)(cn=*" + name
                + "*))";

        NamingEnumeration<SearchResult> results = ldapContext.search(
                searchBaseStr, searchFilter, searchCtls);

        List<LDAPUser> users = new ArrayList<LDAPUser>(0);
        while (results.hasMoreElements()) {
            SearchResult sr = (SearchResult) results.next();
            Attributes attrs = sr.getAttributes();
            LDAPUser user = new LDAPUser();
            user.setName(attrs.get(LDAPAttributes.NAME).toString()
                    .replace("cn: ", ""));
            user.setUserName(attrs.get(LDAPAttributes.USER_NAME).toString()
                    .replace("sAMAccountName: ", ""));
            users.add(user);
        }

        return users;

    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 

connection to ldap:

public static ExtendedDirContext connectToLdap(MessageSource messageSource) {

    try {
        log.debug("connectToLdap");
        String providerUrl = messageSource.getMessage("provider.url", null,
                null);
        String securityPrincipal = messageSource.getMessage(
                "security.principal", null, null);
        String securityCredentials = messageSource.getMessage(
                "security.credentials", null, null);
        String searchBase = messageSource.getMessage("search.base", null,
                null);
        boolean ssl = Boolean.parseBoolean(messageSource.getMessage("ssl",
                null, null));
        LdapContext ldapContext;

        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, providerUrl);
        ldapEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
        ldapEnv.put(Context.SECURITY_PRINCIPAL, securityPrincipal);
        ldapEnv.put(Context.SECURITY_CREDENTIALS, securityCredentials);
        if (ssl)
            ldapEnv.put(Context.SECURITY_PROTOCOL, "ssl");
        // To get rid of the PartialResultException when using Active
        // Directory
        ldapEnv.put(Context.REFERRAL, "follow");
        ldapContext = new InitialLdapContext(ldapEnv, null);
        ExtendedDirContext extendedDirContext = new ExtendedDirContext();
        extendedDirContext.setLdapContext(ldapContext);
        extendedDirContext.setSearchBase(searchBase);
        log.debug("success connection to ldap");
        return extendedDirContext;
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }

}
 

ldap credentials:

provider.url=ldap://abc.techartifact.com:389
security.principal=CN=administrator,CN=Users,DC=techartifact,DC=com
security.credentials=password
search.base=dc=techartifact,dc=com
 

its very difficult to understand why the search takes too much time to retrieve the data.

Solution -To change

ldapEnv.put(Context.REFERRAL, "follow");  to ldapEnv.put(Context.REFERRAL, "ignore");

 

Happy coding with Vinay in techartifact…