user_management


User Management examples
The examples in this folder focus on leveraging CrowdStrike's User Management API to perform administrative operations.
Bulk import, update, and remove users
Consumes a provided user list (JSON format) and creates the user accounts as specified in your Falcon tenant. User roles are assigned as detailed within the file, and can be updated based upon changes made.
A sample of this file (users.json) is included in this folder.
Sample import file format
Running the program
In order to run this demonstration, you will need access to CrowdStrike API keys with the following scope:
User Management
READ, WRITE
Execution syntax
The following arguments are accepted at run time.
-h
--help
show this help message and exit
-d DATA_FILE
--data_file DATA_FILE
File name of user data file
-c COMMAND
--command COMMAND
Action to perform
list
add
remove
update
getroles
Defaults to list
-k FALCON_CLIENT_ID
--falcon_client_id FALCON_CLIENT_ID
Falcon Client ID
-s FALCON_CLIENT_SECRET
--falcon_client_secret FALCON_CLIENT_SECRET
Falcon Client Secret
-m CHILD_CID
--mssp CHILD_CID
CID for the child instance you wish to access. (MSSP scenarios only)
-o SORT
--sort SORT
Field to sort by, one of:
firstName
lastName
roles
uid
uuid
Defaults to lastName (asc)
-r
--reverse
Reverse the sort order
-n
--no_color
Disable color output in result displays
-t TABLE_FORMAT
--table_format TABLE_FORMAT
Table format to use for display, one of:
plain
simple
github
grid
fancy_grid
pipe
orgtbl
jira
presto
pretty
psql
rst
mediawiki
moinmoin
youtrack
html
unsafehtml
latext
latex_raw
latex_booktabs
latex_longtable
textile
tsv
Listing users
The default command is list which requires no additional input.
MSSP access
To access child user data, you will need to provide the child CID when you execute the program.
Sorting results
Results may be sorted by column in ascending or descending order using the -o and -r arguments.
Changing table formatting
Table formatting can be adjusted using the -t argument. A complete list of available formats can be found in the arguments table above, or by using the -h argument to pull up command-line help.
Adding users
If your user import file is properly formatted, you can import the entire file with the following command.
You must provide the location of your input file using the
-dargument.
Removing users
Removing users can also be performed based upon your import file contents.
You must provide the location of your input file using the
-dargument.
Updating users
You can update the roles for users within your input file using the update command.
You must provide the location of your input file using the
-dargument.
Listing available roles
A complete listing of available roles within your tenant can be retrieved using the getroles command.
Disabling color formatting
Color formatting may be disabled using the -n argument. This argument may be mixed with any other command line argument.
Command-line help
Command-line help is available via the -h argument.
Example source code
The source code for this example can be found here.
Find Users
This program will output a list of sensor visibility exclusions and their details for either the current CID or in a specific / each Child CID (Flight Control scenarios). This can be used for regular audits of sensor visibility exclusions across multiple CIDs.
Running the program
In order to run this demonstration, you you will need access to CrowdStrike API keys with the following scopes:
ML Exclusions
READ
Flight Control
READ
Sensor Download
READ
[!NOTE] This program can be executed using an API key that is not scoped for the Flight Control (MSSP) and Sensor Download service collections, but will be unable to lookup the current CID (Sensor Download) or access child CIDs (Flight Control).
Execution syntax
This sample leverages simple command-line arguments to implement functionality.
Basic usage
Execute the default example. This will output results in a tabular format for the local tenant only.
This sample supports Environment Authentication, meaning you can execute any of the command lines shown below without providing credentials if you have the values
FALCON_CLIENT_IDandFALCON_CLIENT_SECRETdefined in your environment.
Enable MSSP mode and audit all Flight Control children with the -m argument.
Enable MSSP mode and audit a specific Flight Control child with the -c argument.
API debugging can be enabled using the
-dargument.
Command-line help
Command-line help is available via the -h argument.
Example source code
The source code for this example can be found here.
Get user grants
Asynchronously retrieve a list of all users within the tenant, along with their grants and then write the results to a comma-delimited text file. This solution is automatically Flight Control aware and supports API debugging.
Running the program
In order to run this demonstration, you will need access to CrowdStrike API keys with the following scope:
User Management
READ
Execution syntax
The following arguments are accepted at run time.
-h
--help
show this help message and exit
-d
--debug
Enable API debugging
-o OUTPUT
--output OUTPUT
CSV output file name
-k FALCON_CLIENT_ID
--falcon_client_id FALCON_CLIENT_ID
Falcon Client ID
-s FALCON_CLIENT_SECRET
--falcon_client_secret FALCON_CLIENT_SECRET
Falcon Client Secret
Authentication
For users that have the environment variables FALCON_CLIENT_ID and FALCON_CLIENT_SECRET defined, you do not need to provide authentication detail on the command line.
If you do not have these values defined, you may provide them at runtime via the command line using the -k and -s arguments.
Outputting results to a different location
You may define the name and location of the resulting output CSV file using the -o command line argument.
Please note: You must provide the trailing slash to specify a directory. (
/= Mac / Linux,\= Windows)
Output to a file
Output to a directory
Enabling API debugging.
API debugging may be enabled with the -d command line argument.
Command-line help
Command-line help is available via the -h argument.
Example source code
The source code for this example can be found here.
Last updated
Was this helpful?