{"record":{"id":"804352ba7b4b230c","repo":"goharbor/harbor","slug":"failed-to-search-user-in-ldap","errorCode":null,"errorMessage":"failed to search user in ldap","messagePattern":"failed to search user in ldap","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"src/core/auth/ldap/ldap.go","lineNumber":252,"sourceCode":"\tu.Comment = \"from LDAP.\"   // Source is from LDAP\n\n\treturn l.userMgr.Onboard(ctx, u)\n}\n\n// SearchUser -- Search user in ldap\nfunc (l *Auth) SearchUser(ctx context.Context, username string) (*models.User, error) {\n\tvar user models.User\n\ts, err := ldapCtl.Ctl.Session(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err = s.Open(); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load system ldap config, %v\", err)\n\t}\n\tdefer s.Close()\n\tlUsers, err := s.SearchUser(username)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to search user in ldap\")\n\t}\n\n\tif len(lUsers) > 1 {\n\t\tlog.Warningf(\"There are more than one user found, return the first user\")\n\t}\n\tif len(lUsers) > 0 {\n\t\tuser.Username = strings.TrimSpace(lUsers[0].Username)\n\t\tuser.Realname = strings.TrimSpace(lUsers[0].Realname)\n\t\tuser.Email = strings.TrimSpace(lUsers[0].Email)\n\n\t\tlog.Debugf(\"Found ldap user %v\", user)\n\t} else {\n\t\treturn nil, errors.NotFoundError(nil).WithMessagef(\"no user found: %v\", username)\n\t}\n\n\treturn &user, nil\n}\n","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/core/auth/ldap/ldap.go#L234-L270","documentation":"Error \"failed to search user in ldap\" thrown in goharbor/harbor.","triggerScenarios":"Thrown at src/core/auth/ldap/ldap.go:252 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}