Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
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.
C#
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?
Posted
v2
Comments
mayankkarki 7-Nov-12 1:06am    
Hi,
One more thing I found. If I use directoryEntry and get nTSecurityDescriptor property then it is of type "System.__ComObject" and when I am using directoryAttrbute in searchResponse of ldapConnection then I am getting System.Byte[].

1 solution

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);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900