Is there any way to add a user to a group for an exact time and then delete the user from the group automatically?
e.g.:
CN=testuser1
and CN=testgroup1
Now I want to add the CN=testuser1
to the CN=testgroup1
for 1 day.
After that 1 day the user should leave(shouldn't be a member of the group anymore) CN=testgroup1
automatically.
Is this possible with System.DirectoryServices.AccountManagement;
, System.DirectoryServices;
or is there another solution except a Powershell script?
Hint: I don't want a solution with a powershell script or something like that. It should be done with in my c# program. I have a windows form where I have 3 textboxes:
- Username from AD: searches in the AD for a user (I already have a searcher)
- Groupname from AD: searches in the AD for a group (I already have a searcher)
- and duration: this is where I want to enter the duration how long the user should be in that group (in days)
When I press a button "Add user temporarily to group" the user should be added to that group for a specific time which I can enter in that duration textbox.
Thanks in Advance!