C# &引用;无法将System.Byte[]的对象强制转换为ActiveDs.IADsSecurityDescriptor";
我的问题是我正在使用C# &引用;无法将System.Byte[]的对象强制转换为ActiveDs.IADsSecurityDescriptor";,c#,asp.net,openldap,C#,Asp.net,Openldap,我的问题是我正在使用LDAPconnection类并通过SSL进行连接。我设法获取nTSecurityDescriptor值,但现在获取错误 “无法将System.Byte[]的对象强制转换为ActiveDs.IADsSecurityDescriptor” 我正在使用这样的代码 SearchResponse response = (SearchResponse)connection.SendRequest(request); IADsSecurityDescriptor sd = (IADsSe
LDAPconnection
类并通过SSL进行连接。我设法获取nTSecurityDescriptor值,但现在获取错误
“无法将System.Byte[]的对象强制转换为ActiveDs.IADsSecurityDescriptor”
我正在使用这样的代码
SearchResponse response = (SearchResponse)connection.SendRequest(request);
IADsSecurityDescriptor sd = (IADsSecurityDescriptor)response.Entries[0].Attributes["nTSecurityDescriptor"][0];
有没有什么错误或其他方法可以做到这一点?我终于找到了问题的答案。此类将字节[]转换为有效的安全说明符comobject
ActiveDs.ADsSecurityUtility secUtility = new ActiveDs.ADsSecurityUtility();
ActiveDs.IADsSecurityDescriptor sd = (IADsSecurityDescriptor)secUtility.ConvertSecurityDescriptor((byte[])attribute[0], (int)ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_RAW, (int)ADS_SD_FORMAT_ENUM.ADS_SD_FORMAT_IID);