Program: 89012
Project: 89012
Buggy source:
/** 
 * Connects to the LDAP server. If successful connected, the user is searched. If found, the user data is read and set into firstName and lastName.
 * @param userName User
 * @param password Password
 * @throws LdapConnectorException
 */
public void connect(String userName,String password) throws LdapConnectorException {
  String userRoot=Play.application().configuration().getString("String_Node_Str");
  String groupRoot=Play.application().configuration().getString("String_Node_Str");
  String connectionBind=Play.application().configuration().getString("String_Node_Str").replace("String_Node_Str",userName).replace("String_Node_Str",userRoot);
  String userSearch=Play.application().configuration().getString("String_Node_Str").replace("String_Node_Str",userName);
  String groupSearch=Play.application().configuration().getString("String_Node_Str").replace("String_Node_Str",connectionBind);
  String userFirstName=Play.application().configuration().getString("String_Node_Str");
  String userLastName=Play.application().configuration().getString("String_Node_Str");
  String userEmail=Play.application().configuration().getString("String_Node_Str");
  String groupName=Play.application().configuration().getString("String_Node_Str");
  String studentRole=Play.application().configuration().getString("String_Node_Str");
  String tutorRole=Play.application().configuration().getString("String_Node_Str");
  try {
    this.connection.bind(connectionBind,password);
  }
 catch (  InvalidConnectionException e) {
    e.printStackTrace();
    throw new LdapConnectorException(Messages.get("String_Node_Str"));
  }
catch (  LdapException e) {
    e.printStackTrace();
    throw new LdapConnectorException(Messages.get("String_Node_Str"));
  }
  EntryCursor entCursor;
  try {
    entCursor=this.connection.search(userRoot,userSearch,SearchScope.ONELEVEL,"String_Node_Str");
    entCursor.next();
    Entry entry=entCursor.get();
    this.firstName=entry.get(userFirstName).getString();
    this.lastName=entry.get(userLastName).getString();
    this.email=entry.get(userEmail).getString();
    Logger.info("String_Node_Str" + this.firstName + "String_Node_Str"+ this.lastName+ "String_Node_Str"+ this.email+ "String_Node_Str");
  }
 catch (  LdapException|CursorException e) {
    e.printStackTrace();
    throw new LdapConnectorException(Messages.get("String_Node_Str"));
  }
  try {
    entCursor=connection.search(groupRoot,groupSearch,SearchScope.ONELEVEL,"String_Node_Str");
    String role;
    while (entCursor.next()) {
      Entry entry=entCursor.get();
      role=entry.get(groupName).getString();
      if (role.equals(studentRole)) {
        this.role=AccountRole.STUDENT;
      }
      if (role.equals(tutorRole)) {
        this.role=AccountRole.TUTOR;
      }
    }
  }
 catch (  LdapException|CursorException e) {
    e.printStackTrace();
    throw new LdapConnectorException(Messages.get("String_Node_Str"));
  }
}

Fixed version (ground truth):
/** 
 * Connects to the LDAP ldapServer. If successful connected, the user is searched. If found, the user data is read and set into firstName and lastName.
 * @param userName User
 * @param password Password
 * @throws LdapConnectorException
 */
public void connect(String userName,String password) throws LdapConnectorException {
  String userRoot=Play.application().configuration().getString("String_Node_Str");
  String groupRoot=Play.application().configuration().getString("String_Node_Str");
  String connectionBind=Play.application().configuration().getString("String_Node_Str").replace("String_Node_Str",userName).replace("String_Node_Str",userRoot);
  String userSearch=Play.application().configuration().getString("String_Node_Str").replace("String_Node_Str",userName);
  String groupSearch=Play.application().configuration().getString("String_Node_Str").replace("String_Node_Str",connectionBind);
  String userFirstName=Play.application().configuration().getString("String_Node_Str");
  String userLastName=Play.application().configuration().getString("String_Node_Str");
  String groupName=Play.application().configuration().getString("String_Node_Str");
  String studentRole=Play.application().configuration().getString("String_Node_Str");
  String tutorRole=Play.application().configuration().getString("String_Node_Str");
  LdapNetworkConnection ldapConnection;
  try {
    LdapConnectionConfig connectionConfig=new LdapConnectionConfig();
    connectionConfig.setLdapHost(this.ldapServer);
    connectionConfig.setLdapPort(this.ldapPort);
    connectionConfig.setUseTls(this.ldapStartTls);
    connectionConfig.setCredentials(password);
    connectionConfig.setName(connectionBind);
    ldapConnection=new LdapNetworkConnection(connectionConfig);
    ldapConnection.bind();
  }
 catch (  InvalidConnectionException e) {
    e.printStackTrace();
    throw new LdapConnectorException(Messages.get("String_Node_Str"));
  }
catch (  LdapException e) {
    e.printStackTrace();
    throw new LdapConnectorException(Messages.get("String_Node_Str"));
  }
  EntryCursor entCursor;
  try {
    entCursor=ldapConnection.search(userRoot,userSearch,SearchScope.ONELEVEL,"String_Node_Str");
    entCursor.next();
    Entry entry=entCursor.get();
    this.firstName=entry.get(userFirstName).getString();
    this.lastName=entry.get(userLastName).getString();
    Logger.info("String_Node_Str" + this.firstName + "String_Node_Str"+ this.lastName);
  }
 catch (  LdapException|CursorException e) {
    e.printStackTrace();
    throw new LdapConnectorException(Messages.get("String_Node_Str"));
  }
  try {
    entCursor=ldapConnection.search(groupRoot,groupSearch,SearchScope.ONELEVEL,"String_Node_Str");
    String role;
    while (entCursor.next()) {
      Entry entry=entCursor.get();
      role=entry.get(groupName).getString();
      if (role.equals(studentRole)) {
        this.role=AccountRole.STUDENT;
      }
      if (role.equals(tutorRole)) {
        this.role=AccountRole.TUTOR;
      }
    }
  }
 catch (  LdapException|CursorException e) {
    e.printStackTrace();
    throw new LdapConnectorException(Messages.get("String_Node_Str"));
  }
}