Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(pam): mssql discovery
Andreyccaa4b0afa7e
diff --git a/backend/src/ee/services/pam-discovery/mssql/mssql-discovery-factory.ts b/backend/src/ee/services/pam-discovery/mssql/mssql-discovery-factory.tsnew file mode 100644index 0000000000..e1275613cd--- /dev/null+++ b/backend/src/ee/services/pam-discovery/mssql/mssql-discovery-factory.ts@@ -0,0 +1,301 @@+import slugify from "@sindresorhus/slugify";+import knex from "knex";+import pLimit from "p-limit";+import RE2 from "re2";++import { BadRequestError } from "@app/lib/errors";+import { logger } from "@app/lib/logger";++import { PamAccountType } from "../../pam/pam-enums";+import { executeWithGateway, sweepReachableTargets } from "../pam-discovery-fns";+import {+ TDiscoveredAccount,+ TDiscoveryCredentialAccount,+ TDiscoveryMachineError,+ TDiscoveryScanResult,+ TPamDiscoveryFactory+} from "../pam-discovery-types";++const QUERY_TIMEOUT_MS = 20 * 1000;+const SCAN_CONCURRENCY = 32;+const SWEEP_DIAL_TIMEOUT_MS = 3 * 1000;+const MAX_ACCOUNTS_PER_HOST = 2000;+const MAX_ACCOUNTS_PER_SCAN = 50000;++const SQL_LOGIN_AUTH_METHOD = "sql-login";++// without these a login sees only itself and sa, and reconciliation would treat every other login as gone+const VISIBILITY_QUERY = `SELECT CASE WHEN HAS_PERMS_BY_NAME(NULL, NULL, 'VIEW ANY DEFINITION') = 1 OR HAS_PERMS_BY_NAME(NULL, NULL, 'VIEW ANY SECURITY DEFINITION') = 1 OR HAS_PERMS_BY_NAME(NULL, NULL, 'ALTER ANY LOGIN') = 1 THEN 1 ELSE 0 END AS canSeeLogins`;++// one row past the cap so truncation is detectable; 63 is the longest username a PAM MSSQL account accepts+const ENUMERATION_QUERY = `SELECT TOP (${MAX_ACCOUNTS_PER_HOST + 1}) name FROM sys.server_principals WHERE type = 'S' AND is_disabled = 0 AND name NOT LIKE '##%##' AND LEN(name) <= 63 ORDER BY name`;++const describeDriverError = (err: unknown): string => {+ const { code, name, cause } = err as { code?: string; name?: string; cause?: { code?: string } };+ switch (code) {+ case "ELOGIN":+ return "Login failed for the credential account. Check its password, and that its database exists on this instance.";+ case "EENCRYPT":+ return "The instance requires an encrypted connection. Enable SSL on the credential account.";+ case "ETIMEOUT":+ return "Timed out connecting to the instance";+ default:+ break;+ }+ if (name === "KnexTimeoutError") return "Timed out connecting to the instance";++ switch (cause?.code) {+ case "ECONNREFUSED":+ return "Connection refused";+ case "ECONNRESET":+ return "The connection closed before login. Check that SQL Server is listening on this port and that the gateway can reach it.";+ case "ETIMEDOUT":+ case "ENETUNREACH":+ case "EHOSTUNREACH":+ return "Timed out connecting to the instance";+ case "DEPTH_ZERO_SELF_SIGNED_CERT":+ case "SELF_SIGNED_CERT_IN_CHAIN":+ case "UNABLE_TO_VERIFY_LEAF_SIGNATURE":+ return "TLS verification failed. Add the instance's CA certificate to the credential account, or disable certificate verification.";+ case "ERR_TLS_CERT_ALTNAME_INVALID":+ return "The instance's TLS certificate isn't valid for this target. List the instance by a name on its certificate, or disable certificate verification.";+ default:+ return "Could not enumerate logins on this instance";+ }+};++const describeScanError = (err: unknown): string =>+ err instanceof BadRequestError ? err.message : "Could not enumerate logins on this instance";++const TRAILING_HYPHENS_REGEX = new RE2(/-+$/);++const NO_USABLE_ACCOUNT_MESSAGE =+ "No credential account can be used to scan. SQL Server discovery requires an account that uses SQL Server authentication with a stored password.";++type TMsSqlAccount = {+ host: string;+ port: number;+ database: string;+ sslEnabled: boolean;+ sslRejectUnauthorized: boolean;+ sslCertificate?: string;+ username: string;+ password?: string;+};++const toMsSqlAccount = (account: TDiscoveryCredentialAccount): TMsSqlAccount => {+ const connectionDetails = account.connectionDetails as {+ host: string;+ port: number;+ database: string;+ sslEnabled?: boolean;+ sslRejectUnauthorized?: boolean;+ sslCertificate?: string;+ };+ const credentials = account.credentials as { authMethod?: string; username: string; password?: string };+ return {+ host: connectionDetails.host,+ port: connectionDetails.port,+ database: connectionDetails.database,+ sslEnabled: Boolean(connectionDetails.sslEnabled),+ sslRejectUnauthorized: connectionDetails.sslRejectUnauthorized !== false,+ sslCertificate: connectionDetails.sslCertificate,+ username: credentials.username,+ // NTLM and Kerberos logins authenticate inside the gateway, so the backend can't scan with them+ password: credentials.authMethod === SQL_LOGIN_AUTH_METHOD ? credentials.password : undefined+ };+};++const isUsableAccount = (account: TMsSqlAccount) => Boolean(account.password);++export const msSqlDiscoveryFactory: TPamDiscoveryFactory = ({+ gatewayId,+ configuration,+ credentialAccounts,+ gatewayV2Service+}) => {+ const accounts = credentialAccounts.map(toMsSqlAccount);+ const config = configuration as { hosts: string[] };++ const enumerateInstance = (host: string, port: number, account: TMsSqlAccount) =>+ executeWithGateway(host, port, gatewayId, gatewayV2Service, async (proxyPort) => {+ const options = account.sslEnabled+ ? {+ encrypt: true,+ trustServerCertificate: !account.sslRejectUnauthorized,+ // the driver dials the local proxy, so the certificate is checked against the real host instead+ serverName: host,+ cryptoCredentialsDetails: account.sslCertificate ? { ca: account.sslCertificate } : {}+ }+ : { encrypt: false };+ const db = knex({+ client: "mssql",+ connection: {+ server: "localhost",+ port: proxyPort,+ database: account.database,+ user: account.username,+ password: account.password,+ connectionTimeout: QUERY_TIMEOUT_MS,+ requestTimeout: QUERY_TIMEOUT_MS,+ options+ },+ acquireConnectionTimeout: QUERY_TIMEOUT_MS,+ pool: { min: 0, max: 1 }+ });++ try {+ const [visibility] = await db.raw<{ canSeeLogins: number }[]>(VISIBILITY_QUERY);+ if (visibility?.canSeeLogins !== 1) {+ throw new BadRequestError({+ message:+ "The credential account can only see its own login. Grant it VIEW ANY DEFINITION or ALTER ANY LOGIN to discover every login on the instance."+ });+ }+ const rows = await db.raw<{ name: string }[]>(ENUMERATION_QUERY);+ return rows.map((row) => row.name);+ } catch (err) {+ if (err instanceof BadRequestError) throw err;+ // withGatewayV2Proxy rethrows only the message, so the driver error code has to be mapped here+ logger.warn({ err }, `PAM SQL Server discovery query failed [host=${host}] [port=${port}]`);+ throw new BadRequestError({ message: describeDriverError(err) });+ } finally {+ await db.destroy();+ }+ });++ const scanInstance = async (+ host: string,+ port: number,+ signal: AbortSignal+ ): Promise<{+ accounts: TDiscoveredAccount[];+ error?: TDiscoveryMachineError;+ machine: string;+ complete: boolean;+ }> => {+ const machine = `${host}:${port}`;+ if (signal.aborted) return { accounts: [], machine, complete: false };++ const candidates = [+ ...accounts.filter((a) => a.host === host && a.port === port),+ ...accounts.filter((a) => a.host !== host || a.port !== port)+ ].filter(isUsableAccount);++ let lastError = "No credential account could authenticate";+ for (const account of candidates) {+ try {+ // eslint-disable-next-line no-await-in-loop+ const logins = await enumerateInstance(host, port, account);+ const complete = logins.length <= MAX_ACCOUNTS_PER_HOST;+ if (!complete) {+ logger.warn(+ `PAM SQL Server discovery truncated an instance at the per-instance limit [machine=${machine}] [limit=${MAX_ACCOUNTS_PER_HOST}]`+ );+ }+ return {+ machine,+ complete,+ ...(complete+ ? {}+ : {+ error: {+ machine,+ error: `Instance has more than ${MAX_ACCOUNTS_PER_HOST} logins; only the first ${MAX_ACCOUNTS_PER_HOST} were staged`+ }+ }),+ accounts: logins.slice(0, MAX_ACCOUNTS_PER_HOST).map((login) => ({+ accountType: PamAccountType.MsSQL,+ name: slugify(`${host} ${login}`, { lowercase: true }).slice(0, 64).replace(TRAILING_HYPHENS_REGEX, ""),+ fingerprint: `${machine}:${login}`,+ details: {+ connectionDetails: {+ host,+ port,+ database: account.database,+ sslEnabled: account.sslEnabled,+ sslRejectUnauthorized: account.sslRejectUnauthorized,+ ...(account.sslCertificate ? { sslCertificate: account.sslCertificate } : {})+ },+ credentials: { authMethod: SQL_LOGIN_AUTH_METHOD, username: login }+ }+ }))+ };+ } catch (err) {+ logger.warn({ err }, `PAM SQL Server discovery failed to scan instance [machine=${machine}]`);+ lastError = describeScanError(err);+ }+ }++ if (candidates.length) return { accounts: [], error: { machine, error: lastError }, machine, complete: false };+ return { accounts: [], machine, complete: false };+ };++ const validateConnection = async () => {+ const account = accounts.find(isUsableAccount);+ if (!account) throw new BadRequestError({ message: NO_USABLE_ACCOUNT_MESSAGE });+ await enumerateInstance(account.host, account.port, account).catch((err: unknown) => {+ logger.warn({ err }, `PAM SQL Server discovery connection test failed [host=${account.host}]`);+ throw new BadRequestError({ message: `Unable to connect to SQL Server: ${describeScanError(err)}` });+ });+ };++ const scan = async (signal: AbortSignal): Promise<TDiscoveryScanResult> => {+ if (!accounts.some(isUsableAccount)) throw new BadRequestError({ message: NO_USABLE_ACCOUNT_MESSAGE });++ const targets = [...new Set(config.hosts.map((host) => host.trim()).filter(Boolean))];+ const usablePorts = [...new Set(accounts.filter(isUsableAccount).map((a) => a.port))];+ const candidatePairs = targets.flatMap((host) => usablePorts.map((port) => ({ host, port })));++ const open = await sweepReachableTargets(+ candidatePairs,+ gatewayId,+ gatewayV2Service,+ SWEEP_DIAL_TIMEOUT_MS,+ signal+ );++ const instancesToScan = candidatePairs.filter(+ ({ host, port }) => open.has(`${host}:${port}`) || accounts.some((a) => a.host === host && a.port === port)+ );++ if (!instancesToScan.length) {+ throw new BadRequestError({+ message:+ "None of the targets were reachable on the credential accounts' ports. Check the hosts, that the gateway can reach them, and that SQL Server is listening."+ });+ }++ const limit = pLimit(SCAN_CONCURRENCY);+ const results = await Promise.all(+ instancesToScan.map(({ host, port }) => limit(() => scanInstance(host, port, signal)))+ );++ const discovered: TDiscoveredAccount[] = [];+ const scannedAccountMachines: string[] = [];+ let droppedInstances = 0;+ for (const result of results) {+ if (discovered.length + result.accounts.length > MAX_ACCOUNTS_PER_SCAN) {+ droppedInstances += 1;+ } else {+ discovered.push(...result.accounts);+ if (result.complete) scannedAccountMachines.push(result.machine);+ }+ }+ if (droppedInstances) {+ logger.warn(+ `PAM SQL Server discovery dropped instances at the per-scan limit [instances=${droppedInstances}] [limit=${MAX_ACCOUNTS_PER_SCAN}]`+ );+ }++ return {+ accounts: discovered,+ machineErrors: results.flatMap((r) => (r.error ? [r.error] : [])),+ dependencies: [],+ scannedDependencyMachines: [],+ scannedAccountMachines+ };+ };++ return { validateConnection, scan };+};diff --git a/backend/src/ee/services/pam-discovery/mssql/mssql-discovery-schemas.ts b/backend/src/ee/services/pam-discovery/mssql/mssql-discovery-schemas.tsnew file mode 100644index 0000000000..1bba8020f2--- /dev/null+++ b/backend/src/ee/services/pam-discovery/mssql/mssql-discovery-schemas.ts@@ -0,0 +1,8 @@+import { z } from "zod";++import { DiscoveryHostsSchema } from "../pam-discovery-targets";++export const MsSqlDiscoveryConfigSchema = z.object({+ hosts: DiscoveryHostsSchema,+ credentialAccountIds: z.array(z.string().uuid()).min(1).max(50)+});diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-enums.ts b/backend/src/ee/services/pam-discovery/pam-discovery-enums.tsindex 686053516d..62af9a78a9 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-enums.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-enums.ts@@ -1,7 +1,8 @@export enum PamDiscoveryType {ActiveDirectory = "active-directory",Unix = "unix",- Postgres = "postgres"+ Postgres = "postgres",+ MsSQL = "mssql"}export enum PamDiscoverySchedule {diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-factory.ts b/backend/src/ee/services/pam-discovery/pam-discovery-factory.tsindex c667ada957..63459f1810 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-factory.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-factory.ts@@ -1,4 +1,5 @@import { activeDirectoryDiscoveryFactory } from "./active-directory/active-directory-discovery-factory";+import { msSqlDiscoveryFactory } from "./mssql/mssql-discovery-factory";import { PamDiscoveryType } from "./pam-discovery-enums";import { TPamDiscoveryFactory } from "./pam-discovery-types";import { postgresDiscoveryFactory } from "./postgres/postgres-discovery-factory";@@ -7,5 +8,6 @@ import { unixDiscoveryFactory } from "./unix/unix-discovery-factory";export const PAM_DISCOVERY_FACTORY_MAP: Record<PamDiscoveryType, TPamDiscoveryFactory> = {[PamDiscoveryType.ActiveDirectory]: activeDirectoryDiscoveryFactory,[PamDiscoveryType.Unix]: unixDiscoveryFactory,- [PamDiscoveryType.Postgres]: postgresDiscoveryFactory+ [PamDiscoveryType.Postgres]: postgresDiscoveryFactory,+ [PamDiscoveryType.MsSQL]: msSqlDiscoveryFactory};diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-schemas.ts b/backend/src/ee/services/pam-discovery/pam-discovery-schemas.tsindex 3d808ac769..f603ac0157 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-schemas.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-schemas.ts@@ -2,6 +2,7 @@ import { z } from "zod";import { PamAccountType } from "../pam/pam-enums";import { ActiveDirectoryDiscoveryConfigSchema } from "./active-directory/active-directory-discovery-schemas";+import { MsSqlDiscoveryConfigSchema } from "./mssql/mssql-discovery-schemas";import { PamDiscoveryType } from "./pam-discovery-enums";import { PostgresDiscoveryConfigSchema } from "./postgres/postgres-discovery-schemas";import { UnixDiscoveryConfigSchema } from "./unix/unix-discovery-schemas";@@ -24,6 +25,12 @@ export const DISCOVERY_TYPE_CONFIGS = {icon: "Postgres.png",credentialAccountType: PamAccountType.Postgres,configuration: PostgresDiscoveryConfigSchema+ },+ [PamDiscoveryType.MsSQL]: {+ name: "Microsoft SQL Server",+ icon: "MsSql.png",+ credentialAccountType: PamAccountType.MsSQL,+ configuration: MsSqlDiscoveryConfigSchema}} as const satisfies Partial<Record<diff --git a/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts b/backend/src/ee/services/pam-discovery/pam-discovery-source-service.tsindex a9f862680b..fa8bf21a69 100644--- a/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts+++ b/backend/src/ee/services/pam-discovery/pam-discovery-source-service.ts@@ -226,7 +226,11 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServic// discovery transmits a password to every scanned host, so a password account may only be used by an actor// allowed to view its secret- if (account.accountType === PamAccountType.SSH || account.accountType === PamAccountType.Postgres) {+ if (+ account.accountType === PamAccountType.SSH ||+ account.accountType === PamAccountType.Postgres ||+ account.accountType === PamAccountType.MsSQL+ ) {const { decryptor } = await getProjectCipher(projectId);const { authMethod } = decryptToObject(account.encryptedCredentials, decryptor) as { authMethod?: string };@@ -236,10 +240,16 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServic});}+ if (account.accountType === PamAccountType.MsSQL && authMethod !== "sql-login") {+ throw new BadRequestError({+ message: `SQL Server account '${account.name}' uses Windows authentication, which cannot scan. Select an account that uses SQL Server authentication.`+ });+ }+const sendsPassword =account.accountType === PamAccountType.Postgres? authMethod !== PamPostgresAuthMethod.AwsIam- : authMethod === PamSshAuthMethod.Password;+ : authMethod === PamSshAuthMethod.Password || authMethod === "sql-login";if (sendsPassword) {await checkAccountAccess(permissionService,@@ -486,8 +496,12 @@ export const pamDiscoverySourceServiceFactory = (deps: TPamDiscoverySourceServicconst goneAccounts = storedAccounts.filter((a) => {if (seenFingerprints.has(a.fingerprint)) return false;if (a.accountType === PamAccountType.WindowsAd) return true;- if (a.accountType === PamAccountType.Windows || a.accountType === PamAccountType.Postgres) {- // fingerprints are `${domain}:${computerObjectGUID}:${username}` and `${host}:${port}:${rolname}`; in+ if (+ a.accountType === PamAccountType.Windows ||+ a.accountType === PamAccountType.Postgres ||+ a.accountType === PamAccountType.MsSQL+ ) {+ // fingerprints are `${domain}:${computerObjectGUID}:${username}` and `${host}:${port}:${login}`; in// both the machine key is the first two segments, matching what the provider reports as re-checkedconst machineKey = a.fingerprint.split(":").slice(0, 2).join(":");return scannedMachines.has(machineKey);diff --git a/backend/src/ee/services/pam/CLAUDE.md b/backend/src/ee/services/pam/CLAUDE.mdindex c78323537d..e5721e8849 100644--- a/backend/src/ee/services/pam/CLAUDE.md+++ b/backend/src/ee/services/pam/CLAUDE.md@@ -197,7 +197,8 @@ for import into a folder. Type registry is `DISCOVERY_TYPE_CONFIGS`; providers r`{ validateConnection, scan }` and never touch the DB — the service owns encryption, staging, andfingerprint dedupe. Discovery runs everything **through the gateway** (SSH-exec / port-sweep / WinRM RPCs),so `ssh2` is never used on the backend and scans produce no session rows, recordings, or session audits.-Current types: Active Directory and Unix.+Current types: Active Directory, Unix, PostgreSQL, and Microsoft SQL Server. `withGatewayV2Proxy` rethrows a callback's+error as a `BadRequestError` carrying only its message, so a provider maps driver error codes inside the callback.**Staleness (Windows).** After a completed scan, discovered accounts it no longer finds are reconciled:never-imported ones are deleted, imported ones are flagged stale (reappearing self-heals). Only accounts in adiff --git a/docs/docs.json b/docs/docs.jsonindex 76913891be..7ae95b9f34 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -753,7 +753,8 @@"documentation/platform/pam/discovery/overview","documentation/platform/pam/discovery/active-directory","documentation/platform/pam/discovery/unix",- "documentation/platform/pam/discovery/postgres"+ "documentation/platform/pam/discovery/postgres",+ "documentation/platform/pam/discovery/mssql"]},{diff --git a/docs/documentation/platform/pam/discovery/mssql.mdx b/docs/documentation/platform/pam/discovery/mssql.mdxnew file mode 100644index 0000000000..351900c568--- /dev/null+++ b/docs/documentation/platform/pam/discovery/mssql.mdx@@ -0,0 +1,91 @@+---+title: "Microsoft SQL Server discovery"+sidebarTitle: "Microsoft SQL Server"+description: "Scan Microsoft SQL Server instances for SQL logins and import them into PAM."+---++Microsoft SQL Server discovery scans a set of SQL Server instances, lists the SQL logins on each one, stages them for review, and lets you import them into PAM as [MS SQL accounts](/documentation/platform/pam/accounts/mssql). You list the instances to scan and the MS SQL accounts to scan with.++All scan traffic is tunneled through an Infisical [Gateway](/documentation/platform/gateways/overview).++<Accordion title="How it works">+ A SQL Server scan connects entirely through the Gateway:++ 1. Each target you list is one instance to scan. The gateway resolves hostnames in the target network.+ 2. Discovery probes each target on the ports of your credential accounts and skips unreachable targets.+ 3. For each reachable target, discovery tries the credential account whose host and port match the target first, then the other accounts in turn.+ 4. Discovery stages each login it finds as an MS SQL account scoped to that instance, so a login named `sa` on two instances becomes two accounts.++ The run reports any instance that no credential account can scan, and the rest of the scan still completes.+</Accordion>++## Prerequisites++Before creating a Microsoft SQL Server discovery source, make sure you have:++- A [Gateway](/documentation/platform/gateways/overview) (or Gateway pool) with network access to the instances you want to scan+- One or more [MS SQL accounts](/documentation/platform/pam/accounts/mssql) that use SQL Server authentication, to use as credential accounts (discovery reuses each account's port, database, and TLS settings)+- The `VIEW ANY DEFINITION` or `ALTER ANY LOGIN` server permission for each credential account's login, so it can see every login on the instance (members of `sysadmin` and `securityadmin` already have it)+- The [Product Admin](/documentation/platform/pam/concepts/access-control#product-membership) role on your PAM project++## Step 1: Create a source++<Steps>+ <Step>+ Go to **Privileged Access Manager > Discovery** and select **Add Source**.+ </Step>+ <Step>+ Select **Microsoft SQL Server**, then select **Next**.+ </Step>+ <Step>+ Configure the source:++ | Field | Description |+ |-------|-------------|+ | **Name** | A descriptive name (for example, `prod-sql-servers`) |+ | **Credential Accounts** | One or more [MS SQL accounts](/documentation/platform/pam/accounts/mssql) used to connect and scan |+ | **Gateway** | The [Gateway](/documentation/platform/gateways/overview) or Gateway pool that scan traffic tunnels through |+ | **Scan Schedule** | How often to scan automatically: **Manual**, **Daily**, or **Weekly** |+ | **Targets** | IP addresses or hostnames of the instances to scan, one per line or comma-separated |+ </Step>+ <Step>+ Select **Add Source**. The source appears in the **Discovery Sources** table.+ </Step>+</Steps>++<Note>+Discovery only stages enabled SQL logins, and skips Windows logins and SQL Server's internal logins.+</Note>++## Step 2: Run a scan++To start a scan manually, select **Scan Now** from the source's row menu or its detail panel. Scans run in the background, one at a time per source, and sources on a **Daily** or **Weekly** schedule also scan automatically.++## Step 3: Import accounts++<Steps>+ <Step>+ In the **Discovery Sources** table, select the source to open its detail panel.+ </Step>+ <Step>+ From the source's **Staged Accounts** tab, select the accounts you want and select **Import Accounts**.+ </Step>+ <Step>+ Choose a **Destination Folder** and a **Microsoft SQL Server Template**, then select **Import**.+ </Step>+</Steps>++<Warning>+Imported accounts don't include passwords, because discovery doesn't read passwords from SQL Server. Open each imported account and add the password for its login before you use it to connect.+</Warning>++## Next steps++<CardGroup cols={2}>+ <Card title="Discovery overview" icon="radar" href="/documentation/platform/pam/discovery/overview">+ Understand staging, importing, and schedules.+ </Card>+ <Card title="MS SQL accounts" icon="database" href="/documentation/platform/pam/accounts/mssql">+ Learn about the account type used to authenticate scans.+ </Card>+</CardGroup>diff --git a/docs/documentation/platform/pam/discovery/overview.mdx b/docs/documentation/platform/pam/discovery/overview.mdxindex e7f646988c..2a7f37acbc 100644--- a/docs/documentation/platform/pam/discovery/overview.mdx+++ b/docs/documentation/platform/pam/discovery/overview.mdx@@ -39,6 +39,9 @@ Discovery is available to **Product Admins**. See [Access Control](/documentatio<Card title="PostgreSQL" icon="database" href="/documentation/platform/pam/discovery/postgres">Scan PostgreSQL instances for login roles.</Card>+ <Card title="Microsoft SQL Server" icon="database" href="/documentation/platform/pam/discovery/mssql">+ Scan Microsoft SQL Server instances for SQL logins.+ </Card></CardGroup><Note>@@ -100,6 +103,9 @@ Scheduled scans are evaluated once a day, so a source runs on its next scheduled<Card title="PostgreSQL" icon="database" href="/documentation/platform/pam/discovery/postgres">Configure a PostgreSQL discovery source.</Card>+ <Card title="Microsoft SQL Server" icon="database" href="/documentation/platform/pam/discovery/mssql">+ Configure a Microsoft SQL Server discovery source.+ </Card><Card title="Accounts" icon="user-lock" href="/documentation/platform/pam/accounts/overview">Manage the accounts you import.</Card>diff --git a/frontend/src/hooks/api/pam/enums.ts b/frontend/src/hooks/api/pam/enums.tsindex 5fb5b114f7..82dedf509a 100644--- a/frontend/src/hooks/api/pam/enums.ts+++ b/frontend/src/hooks/api/pam/enums.ts@@ -19,7 +19,8 @@ export enum PamAccountType {export enum PamDiscoveryType {ActiveDirectory = "active-directory",Unix = "unix",- Postgres = "postgres"+ Postgres = "postgres",+ MsSQL = "mssql"}export enum PamDiscoverySchedule {diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoveryConfigFields.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoveryConfigFields.tsxindex c1652fdc42..c2b50d02f2 100644--- a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoveryConfigFields.tsx+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoveryConfigFields.tsx@@ -192,6 +192,19 @@ export const HOST_RANGE_SOURCES = {targetsPlaceholder: "192.168.1.10, db-primary.internal",targetsDescription:"IP addresses or hostnames of the instances to scan, one per line or comma-separated. CIDR ranges are not supported."+ },+ [PamDiscoveryType.MsSQL]: {+ accountType: PamAccountType.MsSQL,+ placeholder: "Select SQL Server accounts",+ description:+ "Accounts must use SQL Server authentication and hold VIEW ANY DEFINITION or ALTER ANY LOGIN to see every login. The account's database and TLS settings are reused for the connection.",+ warning:+ "The account password is sent to every instance scanned, including any you don't control. Only list hosts you trust.",+ configKey: "hosts",+ allowCidr: false,+ targetsPlaceholder: "192.168.1.10, sql-primary.internal",+ targetsDescription:+ "IP addresses or hostnames of the instances to scan, one per line or comma-separated. CIDR ranges are not supported."}} as const;diff --git a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsxindex 3f9f74c093..cd33fef29c 100644--- a/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx+++ b/frontend/src/pages/pam/PamDiscoveryPage/components/DiscoverySourceDetailSheet.tsx@@ -377,7 +377,9 @@ export const DiscoverySourceDetailSheet = ({ isOpen, sourceId, onOpenChange }: Pconst { map: accountTypeMap } = usePamAccountTypeMap();const source = sources.find((s) => s.id === sourceId);const typeMeta = discoveryTypes.find((t) => t.type === source?.discoveryType);- const showDependencies = source?.discoveryType !== PamDiscoveryType.Postgres;+ const showDependencies =+ source?.discoveryType !== PamDiscoveryType.Postgres &&+ source?.discoveryType !== PamDiscoveryType.MsSQL;const credentialAccount = adminAccounts.find((a) => a.id === source?.credentialAccountId);const credentialAccountLabel = (() => {if (!credentialAccount) return "View account";