{"record":{"id":"116eb8eba9c6e2b2","repo":"theonedev/onedev","slug":"no-user-search-base-specified","errorCode":null,"errorMessage":"No user search base specified","messagePattern":"No user search base specified","errorType":"validation","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-plugin/server-plugin-authenticator-ldap/src/main/java/io/onedev/server/plugin/authenticator/ldap/LdapAuthenticator.java","lineNumber":253,"sourceCode":"        DirContext ctx = null;\n        DirContext referralCtx = null;\n        try {\n            logger.debug(\"Binding to ldap url '\" + getLdapUrl() + \"'...\");\n            try {\n            \tctx = new InitialDirContext(ldapEnv);\n            } catch (AuthenticationException e) {\n        \t\tthrow new RuntimeException(\"Cannot bind to ldap server '\" + getLdapUrl() + \"': \" + e.getMessage());\n            }\n\n\t\t\tNamingEnumeration<SearchResult> results = null;\n\t\t\tfor (var userSearchBase: getUserSearchBases()) {\n\t\t\t\t results = ctx.search(new CompositeName().add(userSearchBase), \n\t\t\t\t\t\tuserSearchFilter, searchControls);\n\t\t\t\t if (results.hasMore())\n\t\t\t\t\t break;\n\t\t\t}\n\t\t\tif (results == null)\n\t\t\t\tthrow new ExplicitException(\"No user search base specified\");\n\t\t\tif (!results.hasMore())\n\t\t\t\tthrow new UnknownAccountException(\"Unknown account\");\n            \n            SearchResult searchResult = results.next();\n            String userDN = searchResult.getNameInNamespace();\n            if (!searchResult.isRelative()) {\n            \tStringBuilder builder = new StringBuilder();\n                builder.append(StringUtils.substringBefore(searchResult.getName(), \"//\"));\n                builder.append(\"//\");\n                builder.append(StringUtils.substringBefore(\n                \t\tStringUtils.substringAfter(searchResult.getName(), \"//\"), \"/\"));\n                \n                ldapEnv.put(Context.PROVIDER_URL, builder.toString());\n                logger.debug(\"Binding to referral ldap url '\" + builder.toString() + \"'...\");\n                referralCtx = new InitialDirContext(ldapEnv);\n            }\n            if (userDN.startsWith(\"ldap\")) {\n            \tuserDN = StringUtils.substringAfter(userDN, \"//\");","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-plugin/server-plugin-authenticator-ldap/src/main/java/io/onedev/server/plugin/authenticator/ldap/LdapAuthenticator.java#L235-L271","documentation":"OneDev's LDAP authenticator loops over the configured user search bases, searching each until it finds results. The loop assigns 'results' but if the getUserSearchBases() list is empty, the loop body never runs and 'results' stays null, so this ExplicitException is thrown: no user search base was configured.","triggerScenarios":"authenticate() is called for an LDAP authenticator whose 'User Search Bases' list contains zero entries — the for-loop over search bases never executes and results remains null.","commonSituations":"Administrator left the user search base field blank when creating the LDAP/AD authentication connector; configuration imported or cloned without search bases; an upgrade cleared the field.","solutions":["Edit the LDAP authenticator in OneDev (Admin > Authentication) and set at least one user search base DN, e.g. 'ou=People,dc=example,dc=com'.","Verify the base DN matches your directory structure using ldapsearch.","If migrating config, re-enter the search bases that were lost.","Test the authenticator by signing in with an LDAP user afterwards."],"exampleFix":"// OneDev authenticator config\n// before: User Search Bases: (empty)\n// after:  User Search Bases: [\"ou=People,dc=example,dc=com\"]","handlingStrategy":"validation","validationCode":"// Check LDAP authenticator config before use:\nif (authenticator.getUserSearchBases() == null || authenticator.getUserSearchBases().isEmpty())\n    throw new IllegalStateException(\"LDAP authenticator requires at least one user search base\");","typeGuard":"boolean ldapConfigValid(LdapAuthenticator a) {\n    return a.getUserSearchBases() != null && !a.getUserSearchBases().isEmpty()\n        && a.getLdapUrl() != null && !a.getLdapUrl().isBlank();\n}","tryCatchPattern":"try {\n    auth.authenticate(token);\n} catch (ExplicitException e) {\n    // misconfiguration, not a login failure: fix authenticator settings in Admin > Authentication\n}","preventionTips":["Always fill in User Search Bases when creating an LDAP connector","Validate the config with ldapsearch before saving","Review authenticator settings after upgrades or config imports"],"tags":["ldap","authentication","missing-config"],"backgroundTag":"missing-required-config-field","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}