{"record":{"id":"2921689df52896c3","repo":"Budibase/budibase","slug":"domain-must-be-provided-for-ntlm-config","errorCode":null,"errorMessage":"Domain must be provided for NTLM config","messagePattern":"Domain must be provided for NTLM config","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/server/src/integrations/microsoftSqlServer.ts","lineNumber":322,"sourceCode":"          const response = await clientApp.acquireTokenByClientCredential({\n            scopes: [\"https://database.windows.net/.default\"],\n            azureRegion: \"DisableMsalForceRegion\",\n          })\n\n          clientCfg.authentication = {\n            type: \"azure-active-directory-access-token\",\n            options: {\n              token: response!.accessToken,\n            },\n          }\n          break\n        }\n        case MSSQLConfigAuthType.NTLM: {\n          const { domain, trustServerCertificate } =\n            this.config.ntlmConfig || {}\n\n          if (!domain) {\n            throw Error(\"Domain must be provided for NTLM config\")\n          }\n\n          clientCfg.authentication = {\n            type: \"ntlm\",\n            // @ts-expect-error - username and password not required for NTLM\n            options: {\n              domain,\n            },\n          }\n          clientCfg.options ??= {}\n          clientCfg.options.trustServerCertificate = !!trustServerCertificate\n          break\n        }\n        case null:\n        case undefined:\n          break\n        default:\n          utils.unreachable(this.config)","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/integrations/microsoftSqlServer.ts#L304-L340","documentation":"The Microsoft SQL Server integration validates its config in connect() before creating a client. When authentication type is NTLM, an ntlmConfig object with a non-empty domain is mandatory; if domain is missing/empty the integration throws 'Domain must be provided for NTLM config'. This fails fast rather than producing a confusing mssql driver error later.","triggerScenarios":"Any datasource operation (testConnection, buildSchema, read, create...) on an MSSQL integration whose config.authType === 'ntlm' but whose ntlmConfig.domain is undefined or empty string.","commonSituations":"Creating the datasource via JSON import/API and omitting ntlmConfig entirely; filling username/password but not the domain field; older configs created before NTLM support that were switched to NTLM auth without adding the domain.","solutions":["Edit the datasource in the builder and set the Domain field under NTLM configuration (e.g. 'CORP' or 'corp.example.com').","If updating via API/JSON, add ntlmConfig: { domain: '...', ... } to the datasource config and re-test the connection.","If your server does not actually use NTLM, switch authentication type to 'sql' (username/password) instead.","Re-run Test Connection after the change to confirm."],"exampleFix":"// before\n{ authType: \"ntlm\", user: \"svc\", password: \"***\" }\n// after\n{ authType: \"ntlm\", user: \"svc\", password: \"***\", ntlmConfig: { domain: \"CORP\", trustServerCertificate: true } }","handlingStrategy":"validation","validationCode":"if (config.authType === \"ntlm\" && !config.ntlmConfig?.domain) {\n  throw new Error(\"NTLM auth requires ntlmConfig.domain\")\n}","typeGuard":"const hasNtlmDomain = (\n  c: MSSQLConfig\n): c is MSSQLConfig & { ntlmConfig: { domain: string } } =>\n  c.authType === MSSQLConfigAuthType.NTLM &&\n  typeof c.ntlmConfig?.domain === \"string\" && c.ntlmConfig.domain.length > 0","tryCatchPattern":"try {\n  await datasource.testConnection()\n} catch (e) {\n  if (String(e?.message).includes(\"Domain must be provided for NTLM\")) {\n    promptUserForNtlmDomain()\n  }\n}","preventionTips":["Fill every NTLM field (domain, username, password) when selecting NTLM auth","Validate datasource JSON imports against the config schema before saving","Use SQL auth instead of NTLM if no AD domain applies","Always run Test Connection right after configuring the datasource"],"tags":["mssql","configuration","ntlm","integration"],"backgroundTag":"missing-config-field","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}