{"_id":"@bun-win32/ntdsapi","_rev":"3-757520f7fa26bc157f97ac244cc438b4","name":"@bun-win32/ntdsapi","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"@bun-win32/ntdsapi","version":"1.0.0","keywords":["bun","ffi","win32","windows","ntdsapi","active-directory","spn","bindings","typescript","dll"],"author":"Stev Peifer <stev@bell.net>","license":"MIT","_id":"@bun-win32/ntdsapi@1.0.0","maintainers":[{"name":"obscuritysrl","email":"stev@bell.net"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"63ef05b1be7188c649b0be620dcc0bd2e218fb6b","tarball":"https://registry.npmjs.org/@bun-win32/ntdsapi/-/ntdsapi-1.0.0.tgz","fileCount":6,"integrity":"sha512-62DPagftGsXG0rk+/bUW083sjxRkuB9Ng4RdgMLyfRk8rBo2myEEkekmoGftRG9Z4hS+Ti7shbyOJe+w/FuceQ==","signatures":[{"sig":"MEUCIQDTOfxoO9Xu+GyRs8I7bcRbYvFB8A1gII37pbTSA+XKuQIgGB62aNHLUu6bDG+kPuiQXRZt+UmUcIrCu6RvNzn7HRI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":52308},"main":"./index.ts","type":"module","module":"index.ts","shasum":"63ef05b1be7188c649b0be620dcc0bd2e218fb6b","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:spn-forge":"bun ./example/spn-forge.ts","example:directory-diagnostic":"bun ./example/directory-diagnostic.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev@bell.net"},"_integrity":"sha512-62DPagftGsXG0rk+/bUW083sjxRkuB9Ng4RdgMLyfRk8rBo2myEEkekmoGftRG9Z4hS+Ti7shbyOJe+w/FuceQ==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/ntdsapi"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 NTDSAPI (Active Directory) bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","dependencies":{"@bun-win32/core":"1.1.2"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","@bun-win32/kernel32":"1.0.24"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/ntdsapi_1.0.0_1780539754982_0.5971567661924955","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bun-win32/ntdsapi","version":"2.0.0","keywords":["bun","ffi","win32","windows","ntdsapi","active-directory","spn","bindings","typescript","dll"],"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","_id":"@bun-win32/ntdsapi@2.0.0","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dist":{"shasum":"e1cd14138e829f494c0645b6275761a67719b2cf","tarball":"https://registry.npmjs.org/@bun-win32/ntdsapi/-/ntdsapi-2.0.0.tgz","fileCount":6,"integrity":"sha512-3D1AT2HXPhq3oE4uOtVI3jEnsb2HbBQfK0lD1MK9kFY5BQP1BtEBEoRQiAFPuMuA4datLTNMMZjkTpZmZTah7Q==","signatures":[{"sig":"MEYCIQCDMs4WvZaAAQR/aUvNtHlm3aRryLTegJZhwfT8eQxBqgIhAOX0RfPIMCjyU1eRvTxNGRJFe+lc3OSyrljH16hxvr82","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":54394},"main":"./index.ts","type":"module","module":"index.ts","shasum":"e1cd14138e829f494c0645b6275761a67719b2cf","engines":{"bun":">=1.1.0"},"exports":{".":"./index.ts"},"private":false,"scripts":{"example:spn-forge":"bun ./example/spn-forge.ts","example:directory-diagnostic":"bun ./example/directory-diagnostic.ts"},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"_integrity":"sha512-3D1AT2HXPhq3oE4uOtVI3jEnsb2HbBQfK0lD1MK9kFY5BQP1BtEBEoRQiAFPuMuA4datLTNMMZjkTpZmZTah7Q==","repository":{"url":"git://github.com/ObscuritySRL/bun-win32.git","type":"git","directory":"packages/ntdsapi"},"_npmVersion":"10.8.3","description":"Zero-dependency, zero-overhead Win32 NTDSAPI (Active Directory) bindings for Bun (FFI) on Windows.","directories":{},"sideEffects":false,"_nodeVersion":"26.3.0","dependencies":{"@bun-win32/core":"2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"@types/bun":"latest","@bun-win32/kernel32":"2.0.0"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/ntdsapi_2.0.0_1782435482913_0.3744299332356682","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"author":"Stev Peifer <stev.p@outlook.com>","bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"dependencies":{"@bun-win32/core":"2.0.1"},"description":"Zero-dependency, zero-overhead Win32 NTDSAPI (Active Directory) bindings for Bun (FFI) on Windows.","devDependencies":{"@bun-win32/kernel32":"2.0.1","@types/bun":"latest"},"exports":{".":"./index.ts"},"license":"MIT","module":"index.ts","name":"@bun-win32/ntdsapi","peerDependencies":{"typescript":"^5"},"private":false,"homepage":"https://github.com/ObscuritySRL/bun-win32#readme","repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/ntdsapi"},"type":"module","version":"2.0.1","main":"./index.ts","keywords":["bun","ffi","win32","windows","ntdsapi","active-directory","spn","bindings","typescript","dll"],"sideEffects":false,"engines":{"bun":">=1.1.0"},"scripts":{"example:spn-forge":"bun ./example/spn-forge.ts","example:directory-diagnostic":"bun ./example/directory-diagnostic.ts"},"_id":"@bun-win32/ntdsapi@2.0.1","_integrity":"sha512-PsOV3mu3G42FoZTyAqzlzrklEmBfFuLamL4qOWhSFMmLiYdV6hgMak1AShaOUORRl34pGCEbBWgudqM6yJeyfQ==","_nodeVersion":"26.3.0","_npmVersion":"10.8.3","shasum":"c3b0d67b550ba6302d4daacb0b44a8358f5c175c","dist":{"integrity":"sha512-PsOV3mu3G42FoZTyAqzlzrklEmBfFuLamL4qOWhSFMmLiYdV6hgMak1AShaOUORRl34pGCEbBWgudqM6yJeyfQ==","shasum":"c3b0d67b550ba6302d4daacb0b44a8358f5c175c","tarball":"https://registry.npmjs.org/@bun-win32/ntdsapi/-/ntdsapi-2.0.1.tgz","fileCount":6,"unpackedSize":54394,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCAPF6252RZm1L904WHxpch67U8e+EKivcM8Ywr7KUnpQIhAMzjpPMvMmh9RdOCmhIiFigSwIpwHEGpSykteDXn8m+7"}]},"_npmUser":{"name":"obscuritysrl","email":"stev.p@outlook.com"},"directories":{},"maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ntdsapi_2.0.1_1782438142707_0.31941439479863365"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-04T02:22:34.814Z","modified":"2026-06-26T01:42:22.986Z","1.0.0":"2026-06-04T02:22:35.120Z","2.0.0":"2026-06-26T00:58:03.059Z","2.0.1":"2026-06-26T01:42:22.878Z"},"bugs":{"url":"https://github.com/ObscuritySRL/bun-win32/issues"},"author":"Stev Peifer <stev.p@outlook.com>","license":"MIT","homepage":"https://github.com/ObscuritySRL/bun-win32#readme","keywords":["bun","ffi","win32","windows","ntdsapi","active-directory","spn","bindings","typescript","dll"],"repository":{"type":"git","url":"git://github.com/ObscuritySRL/bun-win32.git","directory":"packages/ntdsapi"},"description":"Zero-dependency, zero-overhead Win32 NTDSAPI (Active Directory) bindings for Bun (FFI) on Windows.","maintainers":[{"name":"obscuritysrl","email":"stev.p@outlook.com"}],"readme":"# @bun-win32/ntdsapi\n\nZero-dependency, zero-overhead Win32 NTDSAPI (Active Directory client) bindings for [Bun](https://bun.sh) on Windows.\n\n## Overview\n\n`@bun-win32/ntdsapi` exposes the `ntdsapi.dll` exports using [Bun](https://bun.sh)'s FFI. It provides a single class, `Ntdsapi`, which lazily binds native symbols on first use. You can optionally preload a subset or all symbols up-front via `Preload()`.\n\nNTDSAPI is the Active Directory client surface: bind to a directory (`DsBind*`), translate object names between formats (`DsCrackNames`), forge and register Kerberos Service Principal Names (`DsGetSpn` / `DsClientMakeSpnForTargetServer` / `DsWriteAccountSpn`), enumerate sites/servers/roles/domain-controllers, drive replication (`DsReplicaSync` / `DsReplicaAdd` / `DsReplicaGetInfo`), and migrate SID history. All 81 documented exports are bound — the SPN and syntactical name-translation calls work with no domain at all.\n\nThe bindings are strongly typed for a smooth DX in TypeScript.\n\n## Features\n\n- [Bun](https://bun.sh)-first ergonomics on Windows 10/11.\n- Direct FFI to `ntdsapi.dll` (directory bind, name cracking, SPNs, replication, sites/roles, SID history).\n- In-source docs in `structs/Ntdsapi.ts` with links to Microsoft Docs.\n- Lazy binding on first call; optional eager preload (`Ntdsapi.Preload()`).\n- No wrapper overhead; calls map 1:1 to native APIs.\n- Strongly-typed Win32 aliases and enums (see `types/Ntdsapi.ts`).\n\n## Requirements\n\n- [Bun](https://bun.sh) runtime\n- Windows 10 or later\n\n## Installation\n\n```sh\nbun add @bun-win32/ntdsapi\n```\n\n## Quick Start\n\n```ts\nimport Ntdsapi from '@bun-win32/ntdsapi';\n\n// Construct a Kerberos SPN for a target server — no domain required.\nconst serviceClass = Buffer.from('HOST\\0', 'utf16le');\nconst serviceName = Buffer.from('dc01.fabrikam.com\\0', 'utf16le');\nconst len = Buffer.alloc(4);\nlen.writeUInt32LE(512, 0);\nconst spn = Buffer.alloc(512 * 2);\n\nif (Ntdsapi.DsClientMakeSpnForTargetServerW(serviceClass.ptr!, serviceName.ptr!, len.ptr, spn.ptr!) === 0) {\n  console.log('SPN:', spn.toString('utf16le', 0, (len.readUInt32LE(0) - 1) * 2));\n}\n\n// Mint and release an alternate-credential handle.\nconst pAuth = Buffer.alloc(8);\nconst user = Buffer.from('jeff@fabrikam.com\\0', 'utf16le');\nif (Ntdsapi.DsMakePasswordCredentialsW(user.ptr!, null, null, pAuth.ptr) === 0) {\n  const handle = pAuth.readBigUInt64LE(0);\n  Ntdsapi.DsFreePasswordCredentials(handle); // always pair with DsMakePasswordCredentials\n}\n```\n\n> [!NOTE]\n> AI agents: see `AI.md` for the package binding contract and source-navigation guidance. It explains how to use the package without scanning the entire implementation.\n\n## Examples\n\nRun the included examples:\n\n```sh\nbun run example/spn-forge.ts\nbun run example/directory-diagnostic.ts\n```\n\n## Notes\n\n- Either rely on lazy binding or call `Ntdsapi.Preload()`.\n- Most functions return a Win32/RPC error code (`0` = `ERROR_SUCCESS`); the `DsFree*` family returns `void`.\n- `DsBind*` returns a directory handle via an out-parameter; always release it with `DsUnBind*`.\n- `DsCrackNames`, `DsGetSpn`, `DsMapSchemaGuids`, `DsListSites`, `DsGetDomainControllerInfo`, etc. allocate result memory in the DLL — read it back via `bun:ffi`'s `read.ptr` / `toArrayBuffer`, then free it with the matching `DsFree*` call.\n- `DsCrackNames*` with `DS_NAME_FLAG_SYNTACTICAL_ONLY` and a `0n` handle works entirely client-side (no domain).\n- Windows only. Bun runtime required.\n- **SAL types & naming:** nullability is in the **type** — `Optional<T>` (formally optional, SAL `_*opt_`) and `Nullable<T>` (plain `[in]`/`[out]` the docs say can be NULL), the null sentinel derived from `T` (`null` for pointers `LP*`/`P*`, `0n` for handles/by-value addresses); direction is in the **parameter name** — `_out` (`_Out_`), `_in_out` (`_Inout_`), `_In_` bare. See `AI.md` and the repo `AGENTS.md`.\n","readmeFilename":"README.md"}