Last post Mar 23, 2010 02:26 PM by utlandsfantomenno1
Mar 23, 2010 11:36 AM|utlandsfantomenno1|LINK
I'm having some trouble with the below code. I can't get it to execute anymore, guessing an account was added with minimal info.
Anyhow, I call my function like this
myArr(p, 1) = GetAdValue(srGroups, "samAccountName")
Where myArr is a string array.
Private Function GetAdValue(ByVal Results As System.DirectoryServices.SearchResult, ByVal PropName As String) As String
If Results.Properties.Contains(PropName) Then
If Results.Properties(PropName).Count > 0 Then
The error message is as the subject indicates "Index was out of range" which suggests that something is emtpy, now I simply don't know how to make any further checks.
Where am I going wrong on this?
Mar 23, 2010 11:47 AM|MetalAsp.Net|LINK
Put a breakpoint and step though your code. I'm sure you'll be able to see what's wrong.
Mar 23, 2010 12:01 PM|utlandsfantomenno1|LINK
Thanks for your response!
Anyhow, the line producing the actual error is:
Something is missing, or is emtpy. And I really don't know how I can do any further checks.
Would love to step through the code. the only problem is that I don't have that kind of access to the server.
Locally I sit with Visual Studio, then I paste the code straight into notepad on the server. I access the server through VPN with restricted rights.
Mar 23, 2010 12:12 PM|MetalAsp.Net|LINK
So you have no way to put a breakpoint on Return Results.Properties(PropName).Item(0).ToString() to see what item(0) is retuning?
Mar 23, 2010 12:22 PM|utlandsfantomenno1|LINK
Nope. Not with my current setup.
I can of course step through the code on my local setup, the problem is I don't get any errors locally.
Mar 23, 2010 12:27 PM|MetalAsp.Net|LINK
OK, well if this is not a live application, maybe go old style; make use of Response.Write() to write out the value of your item to see what you're getting on the server. maybe combine that with a check for NULL on the item. Use as many response.write
as you see fit to get meaningful results. That's all I can think of...
Mar 23, 2010 12:32 PM|utlandsfantomenno1|LINK
It's live, but this feature disables itself when generating errors but I can still run it.
Will try your suggestions and get back in 4-5 hours.
Thanks, now I have something else to try!
Mar 23, 2010 02:26 PM|utlandsfantomenno1|LINK
Seems like the admin has added dirty data. Not sure yet since they've gone home. Seems like they have added contacts as users AND people since I just found them in the AD.
Then, it makes sense I get errors when trying to access values in samAccounName but not mail for example.
If I don't write anything more in this thread, then this was the problem.
Perhaps I can save someone an afternoon of desperation.
Thanks again metalasp, and sorry for sending you on a false goosechase.