Running GAM in Flask IIS Website app

132 views
Skip to first unread message

Dierk Polzin

unread,
Oct 1, 2020, 8:04:51 PM10/1/20
to GAM for G Suite
Does anyone have any understanding why running a subprocess in python 
"gam whatis usernametest" would generate this subprocess error

ERROR: [WinError 5] Access is denied: 'C:\\Windows\\system32\\config\\systemprofile\\.gam'

There is no such thing as .gam

-- I created a user to run the flask app and gave it group ownership of both GAM and the IIS
-- I logged in as that user to create a profile
-- I made that user an administrator.
-- I copied over the working .gam folder in the users home directory.

 -- Starting GAM processing of whatis dierktest - ['C:\\Program Files\\GAM\\gam.exe', 'whatis', 'dierktest']
 env[path] - C:\Program Files\GAM\gam.exe;C:\Python38\Scripts\;C:\Python38\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\GAM\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsAppsC:\Program Files\GAM\gam.exe;C:\Program Files\GAM\gam.exe;C:\Program Files\GAM\gam.exe;


ERROR: [WinError 5] Access is denied: 'C:\\Windows\\system32\\config\\systemprofile\\.gam'

Ross Scroggs

unread,
Oct 1, 2020, 8:20:45 PM10/1/20
to google-ap...@googlegroups.com
Dierk,

Advanced GAM uses one environment variable, GAMCFGDIR, to look for its configuration folder.
If it's not set, it looks in the user's home folder for a folder named ".gam'.
In your case it's looking for 'C:\\Windows\\system32\\config\\systemprofile\\.gam' which you say doesn't exist, thus the error.
I'd make a folder C:\GamConfig and put the GAM configuration data in that folder. 
In your Python main process set the environment variable GAMCFGDIR  to C:\GamConfig.
Edit gam.cfg and set:
cache_dir = C:\GamConfig\gamcache
config_dir = C:\GamConfig

Ross

Dierk Polzin

unread,
Oct 1, 2020, 8:25:12 PM10/1/20
to GAM for G Suite
So If I move my entire .gam file into that folder then I get this error:

ERROR: [WinError 183] Cannot create a file when that file already exists: 'C:\\Windows\\system32\\config\\systemprofile\\.gam'

['C:\\Program Files\\GAM\\gam.exe', 'whatis', 'username']

process = subprocess.run(args, capture_output=True, universal_newlines=True, env=env)

Ross Scroggs

unread,
Oct 1, 2020, 8:37:33 PM10/1/20
to google-ap...@googlegroups.com
Do you have something like this?

env['GAMCFGDIR'] = 'C:\GamConfig'
process = subprocess.run(args, capture_output=True, universal_newlines=True, env=env)

Ross

--
You received this message because you are subscribed to the Google Groups "GAM for G Suite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/fd729057-1d86-4d67-96e9-d1ce4e11a12cn%40googlegroups.com.


--

Dierk Polzin

unread,
Oct 1, 2020, 8:47:41 PM10/1/20
to GAM for G Suite
let me try that..

Dierk Polzin

unread,
Oct 1, 2020, 9:26:35 PM10/1/20
to GAM for G Suite
Hallelujah

Be sure to give write access to your gam_user_iis to the 'C:\GamConfig'

Kim Nilsson

unread,
Oct 4, 2020, 11:28:24 AM10/4/20
to GAM for G Suite
Is Flask some type of container system which lets you run a shell/terminal remotely?

Dierk Polzin

unread,
Oct 4, 2020, 1:07:05 PM10/4/20
to google-ap...@googlegroups.com
I have built a frontend website using python with flask to allow our service desk to search for users and groups our Active Directory and Google using GAM

I am going to expand it over time, for more functionality in account creation, password reset, change, group membership and maintenance.

The Flask framework allows you to use the Model, View, Controller design. It uses all the modern bootstrap javascript and looks great.

What we are using now is 15 to 20 years old and being obsoleted.

Access GAM in a realtime python script introduces a time delay for some searches, so I create a json file of all users settings daily/hourly. But for active changes to google I needed GAM to kick off using the subprocess command in Python.

On Sun, Oct 4, 2020 at 8:28 AM Kim Nilsson <there.is.no...@gmail.com> wrote:
Is Flask some type of container system which lets you run a shell/terminal remotely?

--
You received this message because you are subscribed to a topic in the Google Groups "GAM for G Suite" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-apps-manager/x88etXlMZfo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-apps-man...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-manager/1a9ee6a3-09bc-4e5f-9278-4a7919b7c5f1n%40googlegroups.com.
--
Dierk Polzin
Developer/Analyst | Information Technology
Lewis & Clark College, 615 S. Palatine Hill Road, Portland, OR 97219
Phone: 503-768-7236 -- dpo...@lclark.edu

Learner - Input - Achiever - Intellection - Ideation

Please note that this information may be FERPA protected. All school officials are expected to manage student records in their custody in accordance with all FERPA regulations.

Kim Nilsson

unread,
Oct 4, 2020, 1:26:55 PM10/4/20
to Google Apps Manager
Nice! 
Posted on github perhaps, or closed source? 
Reply all
Reply to author
Forward
0 new messages