How to Retrieve User Name from Active Directory in Acrobat JavaScript
Question details
A user wants to retrieve their first and last name from Active Directory using Acrobat JavaScript to populate a dynamic stamp.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating a dynamic stamp calculation script in Acrobat that requires the user's real first and last name.
- Observed behavior
- Acrobat JavaScript can display the logged-in user's login name, date, and time, but direct queries to Active Directory to retrieve full names are blocked by security restrictions.
Understand that Acrobat JavaScript operates within a secure sandbox environment, meaning direct system-level queries, such as accessing an Active Directory database, are heavily restricted.
Use Acrobat's Built-in Identity Properties
Since direct Active Directory queries are blocked, the best native alternative is using the application's built-in identity object to fetch the user's name.
Acrobat JavaScript cannot directly query external databases like Active Directory due to security protocols. Instead, you must rely on the identity information configured within the Acrobat application itself.
Open Acrobat and go to Edit > Preferences (Windows) or Acrobat > Settings (Mac). Navigate to the 'Identity' category and ensure the user's First and Last Name are entered correctly.
Open the JavaScript editor for your dynamic stamp. Instead of attempting an AD query, use the application's identity object to retrieve the name.
Use the code snippet 'event.value = identity.name;' in your custom calculation script to automatically populate the stamp with the name configured in the preferences.

Populate Data Using an External Application
Use a system-level script or external application to query Active Directory and inject the required data into the PDF workflow.
Looking for a Lightweight PDF and Office Solution?
While complex JavaScript integrations like Active Directory queries are restricted in standard PDF readers for security reasons, managing your everyday PDFs shouldn't be complicated. WPS Office provides a robust, lightweight, and highly compatible suite for editing PDFs, Word documents, Excel spreadsheets, and more.
- 1. Download the Installer: Visit the WPS Office website and download the free installation package for your operating system.
- 2. Install WPS Office: Run the installer and follow the on-screen prompts to set up the software.
- 3. Open Your PDF: Launch WPS Office, select the PDF tab, and open your document to start editing, annotating, or managing pages.

Frequently Asked Questions
Why can't Acrobat JavaScript query Active Directory directly?
Acrobat JavaScript runs in a restricted, sandboxed environment designed to protect users from malicious code execution. Because of these security restrictions, direct system-level database or network queries, such as connecting to Active Directory, are blocked by default.
How do I add my name to a dynamic stamp without Active Directory?
You can use the 'identity.name' property in your JavaScript code. This property pulls the user's name exactly as it is configured in the Acrobat Preferences under the Identity section, bypassing the need for a network query.
Can I use external tools to get Active Directory data into a PDF?
Yes, but it requires a multi-step workaround. You can use system-level tools like PowerShell or C# applications to query Active Directory. Once retrieved, this data can be written to an FDF file or injected via COM/OLE automation, which Acrobat can then read and apply to the document.




