Skip to main content

Simple Powershell Wrapper that Queries MS Active Directory for Users

Project description

msad-query - Microsoft Active Directory Query

Simple wrapper to perform Windows Powershell-based AD User Querys

Usage

Use any of the three methods provided to get domain records returned:

  • getUser
  • getAllUsers
  • getGroupUsers
from msad_query import getUser
import json

record = getUser(accountId="jdoe", domainServer="<your domain server name>")

print(json.dumps(record, indent=4))

Response record:

{
    "distinguishedName": "CN=John Doe,OU=Users,OU=Company,DC=corp,DC=local",
    "enabled": true,
    "givenName": "John",
    "name": "John Doe",
    "objectClass": "user",
    "objectGUID": "54c6640e-a597-45ad-974e-170d53afbb1a",
    "samAccountName": "jdoe",
    "sID": "S-1-5-21-3691830899-5239577749-90497688-2222",
    "surname": "Doe",
    "userPrincipalName": "jdoe@company.com"
}

The response for the other methods are lists of the same format.

Installation

Prerequisites

The machine running this is assumed to be a Windows machine. The Windows Feature 'RSAT-AD-PowerShell' must be installed. This can be installed from within Powershell with the following command:

    Install-WindowsFeature -Name "RSAT-AD-PowerShell" -IncludeAllSubFeature

Using In Projects

Installation:

    pip install msad-query

Cloning For Development

Set up a virtual environment. Once an environment is set up, activate it and add dependencies with the following:

    pip install -r requirements/dev.txt

The dev.txt file includes:

  • BLACK, a code formatter, see notes at the bottom of this file for details
  • setuptools, which provides the support for the building of the package

To run tests:

    python -m unittest discover -s tests/

Code Formatting

Code formatting is done using BLACK. BLACK allows almost no customization to how code is formatted with the exception of line length, which has been set to 119 characters.

Use the following to bulk format files:

    black . -l 144

Creating A New Release

Please do the following when making a new release, most are documented above:

  1. Run tests
  2. Code format
  3. Be sure to update the change log and _metadata.json with version and notes
  4. git add, commit, and push changes
  5. run the following code to generate a wheel:
    python -m build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

msad_query-1.2.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

msad_query-1.2.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file msad_query-1.2.0.tar.gz.

File metadata

  • Download URL: msad_query-1.2.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for msad_query-1.2.0.tar.gz
Algorithm Hash digest
SHA256 e90afcb48498d8197b52c55152fc27ddf9f2ec8951a30dc393db94d34efaff2c
MD5 b80651c3354f2cd14e59be85302e2c8c
BLAKE2b-256 943b683510ea78e0bac4fd9e512d783baf4be86947e87682b47eaa610e025f02

See more details on using hashes here.

Provenance

The following attestation bundles were made for msad_query-1.2.0.tar.gz:

Publisher: publish.yml on joemarchionna/msad-query

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file msad_query-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: msad_query-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for msad_query-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0bbc1c0e839f7fccfdea5a5202aec6d3bc0aa625f284a1ad540d993143398fd7
MD5 1813d6a3ffdff5f9683fdae7c259f621
BLAKE2b-256 9e4ce54ec059dcda3a2885071354f3ae0de736fbb4b148b04ad4f6eab134b33c

See more details on using hashes here.

Provenance

The following attestation bundles were made for msad_query-1.2.0-py3-none-any.whl:

Publisher: publish.yml on joemarchionna/msad-query

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page