I use the temporary (time-based) group membership mechanism in Active Directory for temporary user access to groups.
By means of Powershell, it is very easy to add users:
$ts = New-TimeSpan -Start (Get-Date) -End (Get-date).AddSeconds(50000)
Add-ADGroupMember -Identity "mytest" -Members "kul" -MemberTimeToLive $ts
Then I can view the users and the remaining time and TTL:
(Get-ADGroup 'mytest' -Property member -ShowMemberTimeToLive).member
<TTL=49891>,CN=kul,OU=Company,DC=test,DC=local
How can I use C# / LDAP to add and view users with their counters?
- Adding via C# has already been solved - c# active directory temporary groupmembership?
- But how to implement viewing the remaining TTL time for users? In the response of paragraph 1, there was a link explaining about direct and reverse AD links. How to get this data correctly using
DirectoryEntry
orGroupPrincipal
?