public function updateDb($ldapObject, $userObject)
    {
        if ($userObject == null) {
            $entity = $this->getEntity();
        } else {
            $entity = $userObject;
        }
        if (isset($ldapObject['uid']['0'])) {
            $entity->setUsername($ldapObject['uid']['0']);
            $entity->setDisplayName($ldapObject['cn']['0']);
            $entity->setEmail($ldapObject['mail']['0']);
            $entity->setPassword(md5('HandledByLdap'));
            $entity->setRoles(serialize($this->getLdapRoles($ldapObject)));
            if ($userObject == null) {
                $this->insert($entity, $this->tableName, new HydratorInterface());
            } else {
                $this->update($entity, null, $this->tableName, new HydratorInterface());
            }
        }
        return $entity;
    }