Created
May 5, 2025 09:34
-
-
Save sparcs360/40800c4173c15cd5515fb9f91611fbd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Name: Active Directory User | |
// Description: Look up a User via security-token-generator in GPT | |
import "@johnlindquist/kit"; | |
const gptDomain = await env("DOMAIN_GPT", { | |
initialChoices: ["gpt.aws-us-east-1.gpt.williamhill.plc"], | |
}); | |
const gptRosiAuthKey = await env("ROSI_AUTH_KEY_GPT", { | |
initialChoices: ["DevKey2023"], | |
}); | |
const toList = (list) => { | |
if (!Array.isArray(list) || list.length === 0) { | |
return "_None_"; | |
} | |
return list | |
.sort() | |
.map((r) => "* `" + r + "`") | |
.join("\n"); | |
}; | |
// ################################################################################# | |
const username = await arg("Enter an Active Directory login name..."); | |
setLoading(true); | |
let response; | |
try { | |
response = await get( | |
`http://security-token-generator.central-rtl.${gptDomain}/users/${username}`, | |
{ | |
headers: { | |
rosiauthkey: gptRosiAuthKey, | |
}, | |
validateStatus: (status) => status < 300 || status === 404, | |
} | |
); | |
} finally { | |
setLoading(false); | |
} | |
// ################################################################################# | |
if (response.status === 404) { | |
await beep(); | |
await div(md(`# User \`${username}\` not found`)); | |
} else { | |
const user = response.data; | |
await div( | |
md( | |
`# ${user.commonName} (${user.userId}) | |
* Last Liberty Retail logon was ${ | |
user.lastRetailLogon ? "`" + user.lastRetailLogon + "`" : "_never_" | |
} | |
* Password expires on \`${user.passwordExpiryDate}\` | |
## Application Roles | |
${toList(user.applicationRoles)} | |
## Groups | |
${toList(user.groupNames)} | |
` | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment