如何从C#中的Active Directory获取System .__ ComObject值 [英] How to get a System.__ComObject value from Active Directory in C#

查看:304
本文介绍了如何从C#中的Active Directory获取System .__ ComObject值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过长时间的搜索,我决定问自己有关问题的问题。

After a long period of search I decide to ask my own question about my problem.

我尝试获取Active Directory中某个属性的值,但是我总是得到 System .__ ComObject

I try to get the value of a Property in Active Directory, but I always get a System.__ComObject.

correspondance += compte.Properties["ENTPersonDateNaissance"][0];

我尝试使用:

 Microsoft.VisualBasic.Information.TypeName(compte.Properties["ENTPersonDateNaissance"]

结果是 PropertyValueCollection

但是我不知道如何获得价值?

But I don't know how to get the value?

推荐答案

事实上,变量 compte的类型为DirectoryEntry,我将其切换为SearchResult,现在可以使用以下命令访问它的值:

In fact, the variable "compte" is of type DirectoryEntry, I switched it to SearchResult, and now I can access it value with :

compte.Properties["ENTPersonDateNaissance"][0].ToString()

我希望它能对您有所帮助。

I hope it can help.

这篇关于如何从C#中的Active Directory获取System .__ ComObject值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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