Active Directory和错误“用户代码未处理COMException" [英] Active Directory and error 'COMException was Unhandled by user code'

查看:84
本文介绍了Active Directory和错误“用户代码未处理COMException"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 尝试使用函数赋值时遇到问题

Hi I have a Problem when I try give value using the function

public string AttributeValuesSingleString
    (string attributeName, string objectDn)
{
    string strValue;
    DirectoryEntry ent = new DirectoryEntry(objectDn);
    strValue = ent.Properties[attributeName].Value.ToString();
    ent.Close();
    ent.Dispose();
    return strValue;
}
}



该错误发生在代码如下:



The error occurs at line with code:

strValue = ent.Properties[attributeName].Value.ToString();



以下是内容错误:



Below is the content error:

COMException was Unhandled by user code
Unspecified error



我一直在寻找像我这样的问题,但没有找到好的解决方案.

我尝试在DirectoryEntry中使用代码:



I was looking for problems like me, but I didn''t found good solution.

I try using code in DirectoryEntry:

DirectoryEntry ent = new DirectoryEntry(objectDn,"Administrator","Pass",AuthenticationTypes.Secure);


并且尝试禁用防火墙,但没有任何帮助.


and also tried disabling firewall and nothing has helped.

推荐答案

尝试一下此操作

ent.Properties[attributeName][0].ToString();
Try this

ent.Properties[attributeName][0].ToString();


这篇关于Active Directory和错误“用户代码未处理COMException"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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