[imp] Active Directory问题请回复 [英] [imp] Active Directory Question Pls Reply

查看:74
本文介绍了[imp] Active Directory问题请回复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在使用Active Directorys,我正在尝试检索某些值为

某些属性。


到目前为止没有问题,但是有些属性没有价值,比如

标题,名字等......


当我尝试将这些值与isNothing或IsDbNull进行比较,它仍然会提高System.NullReferenceException。


如何在异常之前捕获它。

我需要检查它什么,然后显示一些消息,否则可用

值。


代码

Dim res As SearchResult

尝试


如果res.Properties(" title")(0)Nothing Then

Response.Write( 没有标题)

否则

Response.Write(res.Properties(" title")(0))

结束如果

Catch es As Exception

Response.Write(es.ToString)

结束尝试


谢谢

问候

Ar vind。

解决方案

Arvind,


我认为它会返回null好吧,但它可能是

返回别的东西。为什么不在观察窗口看一下

已知的null价值回报?一旦你在你的观察窗口看到它,你可以在你的程序中对它进行
代码。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv * @ spam.guard.caspershouse.com


" Arvind P Rangan" < AR ****** @ hotmail.com>在消息中写道

新闻:eY ************** @ TK2MSFTNGP12.phx.gbl ...


我正在使用Active Directorys,我正在尝试检索某些属性的某些值。

直到现在还没有问题,但有些属性没有像<标题,第二个名字等等......

当我尝试将这些值与isNothing或IsDbNull进行比较时,它仍然会提升System.NullReferenceException。

如何在异常之前捕获它。
我需要检查它什么,然后显示一些消息,否则可用
值。

代码
Dim res As SearchResult <尝试

如果res.Properties(" title")(0)Nothing Then
Response.Write(" No title")
其他 Response.Write(res.Properties(" title")(0))
结束如果
Catch es As Exc eption
Response.Write(es.ToString)
结束尝试

谢谢
问候
Arvind。



嗨Arvind,


我不知道Active Directory中值的结构,但是在我之前我是
go寻找它你会先尝试这个。

如果res.Properties(" title")(0)Nothing Then



意味着通常它不存在。


如果res.Properties(" title")(0)= Nothing

表示它存在但具有默认值。


如果这是一个SQL或Access数据库,它是

如果res.Properties(" title")(0)= dbnull.value


你会尝试=什么?


Cor


Cor,

它完全一样

我已经尝试了所提到的所有选项。


DBNull.value不可能因为它不是来自DB。

我需要一些如何将值转换为对象然后检查它。


谢谢

arvind

Cor写道:

嗨Arvind,

我不知道Active Directory中值的结构,但在我寻找它之前,你先试试这个。

如果res.Properties(" title")(0)Nothing Then



意味着它不存在。

如果res.Properties(" title")(0)= Nothing
意味着它存在但是有默认值。

如果这是一个SQL或Access数据库,那么它是
如果res.Properties(" title")(0)= dbnull.value
<你会尝试=什么都没有?

Cor




Hi,

I working on Active Directorys, and am trying to retrive some values for
certain attribute.

No problem till now, but some attributes don''t have values like
Title,Second Name,etc...

When i try to compare those values with isNothing or IsDbNull its still
raising System.NullReferenceException.

How to capture this before going to exception.
I need to check its nothing then display some message else the available
value.

Code
Dim res As SearchResult
Try

If res.Properties("title")(0) Is Nothing Then
Response.Write("No title")
Else
Response.Write(res.Properties("title")(0))
End If
Catch es As Exception
Response.Write(es.ToString)
End Try

Thanks
Regards
Arvind.

解决方案

Arvind,

I would think that it would return null as well, but it might be
returning something else. Why not look in the watch window to see what a
known "null" value returns? Once you see it in your watch window, you can
code against it in your program.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Arvind P Rangan" <ar******@hotmail.com> wrote in message
news:eY**************@TK2MSFTNGP12.phx.gbl...

Hi,

I working on Active Directorys, and am trying to retrive some values for
certain attribute.

No problem till now, but some attributes don''t have values like
Title,Second Name,etc...

When i try to compare those values with isNothing or IsDbNull its still
raising System.NullReferenceException.

How to capture this before going to exception.
I need to check its nothing then display some message else the available
value.

Code
Dim res As SearchResult
Try

If res.Properties("title")(0) Is Nothing Then
Response.Write("No title")
Else
Response.Write(res.Properties("title")(0))
End If
Catch es As Exception
Response.Write(es.ToString)
End Try

Thanks
Regards
Arvind.



Hi Arvind,

I don''t know the structure of values in the Active Directory, but before I
go looking for it will you try first this.

If res.Properties("title")(0) Is Nothing Then


Means normaly it does not exist.

If res.Properties("title")(0)=Nothing
means that it exist but has the default value.

If this is an SQL or Access database it is
If res.Properties("title")(0)=dbnull.value

Will you try = nothing?

Cor


Cor,
Its all the same
I have tried all those option whichu have mentioned.

DBNull.value is not possible as its not from DB.
I need to some how convert the value to object and then check it.

Thanks
arvind
Cor wrote:

Hi Arvind,

I don''t know the structure of values in the Active Directory, but before I
go looking for it will you try first this.

If res.Properties("title")(0) Is Nothing Then



Means normaly it does not exist.

If res.Properties("title")(0)=Nothing
means that it exist but has the default value.

If this is an SQL or Access database it is
If res.Properties("title")(0)=dbnull.value

Will you try = nothing?

Cor




这篇关于[imp] Active Directory问题请回复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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