问题
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