I have an export from a database which i use to create the users in AD. I can add the users to groups etc. The groups are what we call roles, which means that a role has access to resources in the infrastructure.
The users change from role quit often, management want to automatically update group membership What is a good logic to do that, the export that is get does not change.
This is a code snippet what i use to add users to groups. This is done the first time in the script if the user does not exists. You can see i had to create a case statement, because the cn and ldap path are not specified in the database only the role name.
I want to use almost the same logic to update the user groepmembership. This means i have to remove users from roles they no longer need and add them to new roles.
Not possible, because users can have more then one role. There are not much roles, so i think the best way is to delete the user from all the roles and then add them back to the roles according to the export sheet.