goharbor/harbor · error

failed to load system ldap config

Error message

failed to load system ldap config, %v

What it means

Wrapped error in LDAP SearchUser: opening the LDAP session failed because the system LDAP configuration could not be loaded, and the underlying error is embedded.

Solutions

  1. Review the wrapped error and LDAP configuration (URL, TLS, bind settings)
  2. Verify network reachability to the LDAP server
  3. Test LDAP connectivity with the configured settings and retry
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/core/auth/ldap/ldap.go:247 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/ca2abd08f9be3636. Report an issue: GitHub.

Appendix: source

Thrown at src/core/auth/ldap/ldap.go:247

		if strings.Contains(u.Username, "@") {
			u.Email = u.Username
		}
	}
	u.Password = "12345678AbC" // Password is not kept in local db
	u.Comment = "from LDAP."   // Source is from LDAP

	return l.userMgr.Onboard(ctx, u)
}

// SearchUser -- Search user in ldap
func (l *Auth) SearchUser(ctx context.Context, username string) (*models.User, error) {
	var user models.User
	s, err := ldapCtl.Ctl.Session(ctx)
	if err != nil {
		return nil, err
	}
	if err = s.Open(); err != nil {
		return nil, fmt.Errorf("failed to load system ldap config, %v", err)
	}
	defer s.Close()
	lUsers, err := s.SearchUser(username)
	if err != nil {
		return nil, fmt.Errorf("failed to search user in ldap")
	}

	if len(lUsers) > 1 {
		log.Warningf("There are more than one user found, return the first user")
	}
	if len(lUsers) > 0 {
		user.Username = strings.TrimSpace(lUsers[0].Username)
		user.Realname = strings.TrimSpace(lUsers[0].Realname)
		user.Email = strings.TrimSpace(lUsers[0].Email)

		log.Debugf("Found ldap user %v", user)
	} else {
		return nil, errors.NotFoundError(nil).WithMessagef("no user found: %v", username)

View on GitHub (pinned to 7b2fd08cc5)