“Unable to cast object of System.Byte[] to ActiveDs.IADsSecurityDescriptor”

不打扰是莪最后的温柔 提交于 2019-12-08 08:52:40

问题


My problem is that I am using LDAPconnection class and connecting over SSL. I manage to get nTSecurityDescriptor value but now getting error

"Unable to cast object of System.Byte[] to ActiveDs.IADsSecurityDescriptor"

I am using code like this

SearchResponse response = (SearchResponse)connection.SendRequest(request);
IADsSecurityDescriptor sd = (IADsSecurityDescriptor)response.Entries[0].Attributes["nTSecurityDescriptor"][0];

Is there any error or some other way to do this?


回答1:


At last I find the answer of my question. This class convert the byte[] to valid security decriptor 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);


来源:https://stackoverflow.com/questions/13245822/unable-to-cast-object-of-system-byte-to-activeds-iadssecuritydescriptor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!