title: Can't get active directory group details by distinguished name
body: <p>i am trying to get active directory group details by group dn as follows:</p>
  
  <p><strong>1- connect to ldap:</strong></p>
  
  <pre><code>public static LdapContext connectToLdap(String host,
              String userDN, String userPassword,
              boolean ssl) throws Exception {
  
          System.out.println("connectToLdap");
  
          String hostPrefix = "ldap";
          String ldapPort = "389";
          if (ssl) {
              hostPrefix = "ldaps";
              ldapPort = "636";
          }
          String providerUrl = hostPrefix + "://" + host + ":" + ldapPort;
          //System.out.println("####### LDAP URL: " + providerUrl);
          LdapContext ldapContext;
          Hashtable&lt;String, String&gt; ldapEnv = new Hashtable&lt;String, String&gt;(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, userDN);
          ldapEnv.put(Context.SECURITY_CREDENTIALS, userPassword);
          ldapEnv.put("com.sun.jndi.ldap.read.timeout", 1000 * 10 + "");
          if (ssl) {
              ldapEnv.put(Context.SECURITY_PROTOCOL, "ssl");
          }
          ldapEnv.put(Context.REFERRAL, "ignore");
          try {
              ldapContext = new InitialLdapContext(ldapEnv, null);           
              System.out.println("success connection to ldap");
              return ldapContext;
          } catch (Exception e) {
              System.out.println("failure connection to ldap");
              e.printStackTrace();
              return null;
          }
      }
  </code></pre>
  
  <p><strong>2- find group method:</strong></p>
  
  <pre><code>public static boolean isGroupExist(LdapContext ldapContext,
              String domain, String groupDN) {
  
          boolean exist = false;
  
          try {
  
  
              SearchControls searchCtls = new SearchControls();
              searchCtls.setTimeLimit(1000 * 10);
  
              String returnedAttrs[] = {"distinguishedName","cn"};
              searchCtls.setReturningAttributes(returnedAttrs);
  
              searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
  
              String searchFilter = "(&amp;(objectClass=group)(distinguishedName=" + groupDN + "))";
  
              NamingEnumeration&lt;SearchResult&gt; results = ldapContext.search(
                      domain, searchFilter, searchCtls);
  
              while (results.hasMoreElements()) {
                  System.out.println("Success to retrieve active directory group with dn: " + groupDN);
                  SearchResult sr = (SearchResult) results.next();
                  Attributes attrs = sr.getAttributes();
                  String cn=attrs.get("cn").toString();
                  System.out.println(cn);
                  exist=true;
              }
  
          } catch (Exception e) {
              System.out.println("Fail to search in active directory groups");
              e.printStackTrace();
              return false;
          }
  
          return exist;
  }
  </code></pre>
  
  <p>but when i am trying to use the isGroupExist method i am getting the following exception:</p>
  
  <pre><code>javax.naming.OperationNotSupportedException: [LDAP: error code 12 - 0000217A: SvcErr: DSID-0314020F, problem 5010 (UNAVAIL_EXTENSION), data 0
  </code></pre>
  
  <p>please advise why i am getting this exception and how to fix it.</p>