I have a need to manage Kerberos Resource Based Delegation
in C#
(I know it's easier in Powershell
but that is not the requirement). The attribute on the user/computer/service
accounts is msDS-AllowedToActOnBehalfOfOtherIdentity
, but this seems to be some COM
object which I can't seem to deal with in C#
:
static void Main(string[] args)
{
string ou = @"OU=some,OU=ou,DC=corp,DC=com";
string cn = @"someaccount";
DirectoryEntry de = new DirectoryEntry();
de.Username = @"CORP\userwithOUrights";
de.Password = @"password";
de.AuthenticationType = AuthenticationTypes.Secure;
de.Path = $"LDAP://CN={cn},{ou}";
Object a = de.Properties["msDS-AllowedToActOnBehalfOfOtherIdentity"];
}
After this, a
doesn't seem to be anything I can do much with, unlike other properties. It is some COM
object and I need to get the accounts which are in there. Powershell
reports that this property returns a System.DirectoryServices.ActiveDirectorySecurity
object and I see useful methods in this class for decoding the binary format which is stored in AD etc. But this does not seem to be the return type from the property call in C#
.