Program: 52284
Project: 52284
Buggy source:
protected String getDNOfUser(String adminUser,String adminPassword,Context context,String netid){
  String resultDN;
  int ldap_search_scope_value=0;
  try {
    ldap_search_scope_value=Integer.parseInt(ldap_search_scope.trim());
  }
 catch (  Exception e) {
    if (ldap_search_scope != null) {
      log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + ldap_search_scope));
    }
  }
  Hashtable env=new Hashtable(11);
  env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"String_Node_Str");
  env.put(javax.naming.Context.PROVIDER_URL,ldap_provider_url);
  env.put(javax.naming.Context.SECURITY_AUTHENTICATION,"String_Node_Str");
  env.put(javax.naming.Context.SECURITY_PRINCIPAL,adminUser);
  env.put(javax.naming.Context.SECURITY_CREDENTIALS,adminPassword);
  DirContext ctx=null;
  try {
    ctx=new InitialDirContext(env);
    Attributes matchAttrs=new BasicAttributes(true);
    matchAttrs.put(new BasicAttribute(ldap_id_field,netid));
    try {
      SearchControls ctrls=new SearchControls();
      ctrls.setSearchScope(ldap_search_scope_value);
      NamingEnumeration<SearchResult> answer=ctx.search(ldap_provider_url + ldap_search_context,"String_Node_Str",new Object[]{ldap_id_field,netid},ctrls);
      while (answer.hasMoreElements()) {
        SearchResult sr=answer.next();
        resultDN=(sr.getName() + "String_Node_Str" + ldap_search_context);
        String attlist[]={ldap_email_field,ldap_givenname_field,ldap_surname_field,ldap_phone_field};
        Attributes atts=sr.getAttributes();
        Attribute att;
        if (attlist[0] != null) {
          att=atts.get(attlist[0]);
          if (att != null)           ldapEmail=(String)att.get();
        }
        if (attlist[1] != null) {
          att=atts.get(attlist[1]);
          if (att != null)           ldapGivenName=(String)att.get();
        }
        if (attlist[2] != null) {
          att=atts.get(attlist[2]);
          if (att != null)           ldapSurname=(String)att.get();
        }
        if (attlist[3] != null) {
          att=atts.get(attlist[3]);
          if (att != null)           ldapPhone=(String)att.get();
        }
        if (answer.hasMoreElements()) {
        }
 else {
          log.warn(LogManager.getHeader(context,"String_Node_Str",resultDN));
          return resultDN;
        }
      }
    }
 catch (    NamingException e) {
      log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + e));
    }
  }
 catch (  NamingException e) {
    log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + e));
  }
 finally {
    try {
      if (ctx != null)       ctx.close();
    }
 catch (    NamingException e) {
    }
  }
  return null;
}

Fixed version (ground truth):
protected String getDNOfUser(String adminUser,String adminPassword,Context context,String netid){
  String resultDN;
  int ldap_search_scope_value=0;
  try {
    ldap_search_scope_value=Integer.parseInt(ldap_search_scope.trim());
  }
 catch (  Exception e) {
    if (ldap_search_scope != null) {
      log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + ldap_search_scope));
    }
  }
  Hashtable env=new Hashtable(11);
  env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,"String_Node_Str");
  env.put(javax.naming.Context.PROVIDER_URL,ldap_provider_url);
  env.put(javax.naming.Context.SECURITY_AUTHENTICATION,"String_Node_Str");
  env.put(javax.naming.Context.SECURITY_PRINCIPAL,adminUser);
  env.put(javax.naming.Context.SECURITY_CREDENTIALS,adminPassword);
  DirContext ctx=null;
  try {
    ctx=new InitialDirContext(env);
    Attributes matchAttrs=new BasicAttributes(true);
    matchAttrs.put(new BasicAttribute(ldap_id_field,netid));
    try {
      SearchControls ctrls=new SearchControls();
      ctrls.setSearchScope(ldap_search_scope_value);
      NamingEnumeration<SearchResult> answer=ctx.search(ldap_provider_url + ldap_search_context,"String_Node_Str",new Object[]{ldap_id_field,netid},ctrls);
      while (answer.hasMoreElements()) {
        SearchResult sr=answer.next();
        resultDN=(sr.getName() + "String_Node_Str" + ldap_search_context);
        String attlist[]={ldap_email_field,ldap_givenname_field,ldap_surname_field,ldap_phone_field};
        Attributes atts=sr.getAttributes();
        Attribute att;
        if (attlist[0] != null) {
          att=atts.get(attlist[0]);
          if (att != null)           ldapEmail=(String)att.get();
        }
        if (attlist[1] != null) {
          att=atts.get(attlist[1]);
          if (att != null)           ldapGivenName=(String)att.get();
        }
        if (attlist[2] != null) {
          att=atts.get(attlist[2]);
          if (att != null)           ldapSurname=(String)att.get();
        }
        if (attlist[3] != null) {
          att=atts.get(attlist[3]);
          if (att != null)           ldapPhone=(String)att.get();
        }
        if (answer.hasMoreElements()) {
        }
 else {
          log.debug(LogManager.getHeader(context,"String_Node_Str",resultDN));
          return resultDN;
        }
      }
    }
 catch (    NamingException e) {
      log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + e));
    }
  }
 catch (  NamingException e) {
    log.warn(LogManager.getHeader(context,"String_Node_Str","String_Node_Str" + e));
  }
 finally {
    try {
      if (ctx != null)       ctx.close();
    }
 catch (    NamingException e) {
    }
  }
  return null;
}