Hello,
The 401 is happening because an API call is being made with out proper authentication being sent. You first need to authenticate the user using StartAuthentication and AdvanceAuthentication API's. Then, you need to capture the ASPXAUTH cookie that is returned on successfull login from the response of the AdvanceAuthentcaiton API call. You will send the ASPXAUTH cookie value in the header of your next API call as a Bearer token (Header Name: 'Authorization'. Header Value: 'Bearer ValueOfASPXAUTHCookie').
Take a look at this code sample. https://github.com/centrify/Centrify-Samples-DotNet-SIEMUtility. I think this does some of what you are trying to do. This allows you to query Centrify using a list of queries (set in Queries.JSON) and exports the results to CSV files. Once you get this working, you would just need to change the export to CSV code to write to your DB instead. To set up, do the following.
1) Compile to code into binaries.
2) Move binaries to a new folder or working directory (or just use the output directory as your working directory)
3) Create a folder in the workding directory called "Output"
4) Create a folder in the Output folder called "Archive"
5) Modify Queries.Json file and add in any queries that you would like to run (you can create as many as desired)
6) Go to the Centrify Cloud Manager, and set up a security policy for your admin user that has an authentication profile of just username and password. No MFA.
7) Modify the aplication config file in the working directory to have your tenant URL, and your admin credentials for the user with no MFA as its policy.
8) Make sure you set the windows permissions on your working directory to allow read write or you will get write issues
9) Run the app as admin.
10) You should end up with CSV files in the output folder. Modify the code as needed to change it to write to a DB or port the code to a different programming language.
Please contact me at devsupport@centrify.com if you have any other questions or if you would like to have a call to walk through any development topics.
Thank you,
Nick Gamb