由DirectorySearcher从和SearchResponse返回属性值是不同的类型System._comobject和字节数组 [英] Property value returned by DirectorySearcher and SearchResponse are of different type System._comobject and Byte array

查看:276
本文介绍了由DirectorySearcher从和SearchResponse返回属性值是不同的类型System._comobject和字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个网站,以管理Active Directory。
我要检查用户是否有权更改密码或者没有。
所以,我必须找到ntSecurityDescriptor中属性值之后,我不得不扔在IADsSecurityDescriptor。
现在,如果我使用DirectorySearcher类则属性值的类型为 System._ComObject ,然后轻松地铸造为 IADsSecurityDescriptor
但是,当我使用LdapConnection和SearchResponse我得到的类型
的属性值

I am working on a website to manage active directory.
I want to check that whether user has permission to change password or not.
So I have to find "ntSecurityDescriptor" property value after that I have to cast it into IADsSecurityDescriptor.
Now if I use DirectorySearcher class then property value is of type System._ComObject and easily casted to IADsSecurityDescriptor.
But when I use LdapConnection and SearchResponse I get property value of type

byte[] array which is unale to cast to IADsSecityDescriptor.

我收到错误

Unable to cast System.Byte[] to IADsSecurityDescriptor

有一些问题,SearchResponse或我使用某种铸造技术来实现这一目标。 我有一些问题要使用的DirectoryEntry类,所以我只能用LdapConnction类。

Is there some problem with SearchResponse or I have use some kind of casting technique to achieve this. I have some problem to use DirectoryEntry class so I can only use LdapConnction class.

请帮助其紧迫。 谢谢你。

Please help its urgent. Thanks.

推荐答案

最后,我发现我的问题的答案。此类转换的byte [],以有效的安全decriptor comobject。

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);

这篇关于由DirectorySearcher从和SearchResponse返回属性值是不同的类型System._comobject和字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆