473,387 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

ADSI Guru... HELP!

Hi can someone please help!

I have been having issues with the following piece of code! Everytime I run
the application I get:

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:
Line 70: topRow(" ") = "<img src='../images/user.gif'>"
Line 71:
Line 72: If res.Properties("sn").Count > 0 Then
Line 73: If res.Properties("sn")(0) Is Nothing Then
Line 74: Response.Write("Null")

I think this is because the value of "SN" in some records is null or
nothing! Can someone please help!

Thanks
Dim src As DirectorySearcher = New
DirectorySearcher("(&(objectCategory=Person)(objec tClass=user))")
createTable()
src.SearchRoot = de
src.SearchScope = SearchScope.Subtree
For Each res As SearchResult In src.FindAll
Dim topRow As DataRow = ds.Tables("contacts").NewRow
topRow("&nbsp;") = "<img src='../images/user.gif'>"

If res.Properties("sn").Count > 0 Then
If res.Properties("sn")(0) Is Nothing Then
Response.Write("Null")
Else
topRow("Name") = res.Properties("sn")(0)
'topRow("Dept.") =
res.Properties("physicalDeliveryOfficeName")(0)
'topRow("Ext") = res.Properties("telephoneNumber")(0)
'topRow("Email") = res.Properties("mail")(0)

End If
End If

ds.Tables("contacts").Rows.Add(topRow)
Next
DataGrid1.DataSource = ds.Tables("contacts")
DataGrid1.DataBind()

End Sub
Nov 19 '05 #1
1 1047
Don't worry I managed to fix it!

If res.Properties.Contains("physicalDeliveryOfficeNam e") Then
topRow("Dept.") =
CStr(res.Properties("physicalDeliveryOfficeName")( 0))
Else
topRow("Dept.") = ""
End If


"Tim::.." wrote:
Hi can someone please help!

I have been having issues with the following piece of code! Everytime I run
the application I get:

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:
Line 70: topRow(" ") = "<img src='../images/user.gif'>"
Line 71:
Line 72: If res.Properties("sn").Count > 0 Then
Line 73: If res.Properties("sn")(0) Is Nothing Then
Line 74: Response.Write("Null")

I think this is because the value of "SN" in some records is null or
nothing! Can someone please help!

Thanks
Dim src As DirectorySearcher = New
DirectorySearcher("(&(objectCategory=Person)(objec tClass=user))")
createTable()
src.SearchRoot = de
src.SearchScope = SearchScope.Subtree
For Each res As SearchResult In src.FindAll
Dim topRow As DataRow = ds.Tables("contacts").NewRow
topRow(" ") = "<img src='../images/user.gif'>"

If res.Properties("sn").Count > 0 Then
If res.Properties("sn")(0) Is Nothing Then
Response.Write("Null")
Else
topRow("Name") = res.Properties("sn")(0)
'topRow("Dept.") =
res.Properties("physicalDeliveryOfficeName")(0)
'topRow("Ext") = res.Properties("telephoneNumber")(0)
'topRow("Email") = res.Properties("mail")(0)

End If
End If

ds.Tables("contacts").Rows.Add(topRow)
Next
DataGrid1.DataSource = ds.Tables("contacts")
DataGrid1.DataBind()

End Sub

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Miguel Orrego | last post by:
Hi, I have found some code that authenticates users agains a domain using ADSI. I then redirect to another page and pass the username they have entered as a string. However, it would be nice to...
1
by: Ryan Ritten | last post by:
I was wondering if anyone knew how (or if it's even possible) to cache the results of an ADSI call in asp for a longer period of time. Basically what I am doing is I have a website that loads the...
14
by: Arran Pearce | last post by:
Hi, I am looking for a way to use System.DirectoryServices to find all users on a domain whos accounts are either locked out or disabled. I have used ADSIEdit and the mmc schema add-in to try...
10
by: Victor Pereira | last post by:
Hi, I'm trying to rename the Administrator Login, and i want to know if my approach is right: void RenameUsr(string hostname, string admusr) { DirectoryEntry entry = new...
3
by: Roy Osherove | last post by:
Hi folks. I have an ASP.Net application that runs a .Net dll that uses WMI and ADSI(both managed) to connect to a given IIS root and search through it. When not using the ASP.Net client, but...
1
by: Amit | last post by:
Can anyone help regarding programming in ADSI. any source code might help..
3
by: chat_devil | last post by:
hi, does anyone know if it is possible to remove an attribute that can not be read into the ADSI property cache/collection. i'm trying to do an eDirectory password change from .net directory...
16
by: Singulus | last post by:
Hello all, I've searched for similar threads, I've found some bit of useful info here and there, but nevertheless I want to post my questions...So, how can I (we, in fact the forum can benefit...
8
by: John | last post by:
Hi, gurus, How can I implement the following feature in C#: Set objGroup = GetObject("WinNT://" & strComputer & "/" & strGroup & ", group") For Each objMember In objGroup.Members...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.