ADSI & VB.Net 
Author Message
 ADSI & VB.Net

Greetings,
I posted this in microsoft.public.adsi.general, but have had no bites on it.
Can anybody help me here?

I have a program that reads data from our HR Database and updates AD with
the appropriate info. The field I am having problems with is the
physicalDeliveryOfficeName. If the field is empty, I get an
ArgumentOutOfRangeException "Specified argument was out of the range of
valid values. Parameter name: Index was out of range.  Must be non-negative
and less than the size of the collection." This is when it hits line 3 of
the code below.

The DataRow is working perfectly. For testing you can replace r("Mailstop")
with "Test"

If I manually edit the Office field in AD and put anything in it, the code
works fine and changes the field to the proper text.

Here is the code I am playing with:

[other code here to pull in hr info into a table and query ad for user
objects]
Dim r As DataRow
If str_physicalDeliveryOfficeName <> r("Mailstop") Then
    User.Properties("physicalDeliveryOfficeName")(0) = r("Mailstop")
    b_Update_Needed = True
    If strLogging = "verbose" Then
        PrintLine(4, Now() & " Setting physicalDeliveryOfficeName to " &
r("Mailstop"))
    End If
End If



Wed, 22 Dec 2004 05:01:30 GMT  
 ADSI & VB.Net
We don't know the objects you're using, but, have you tried to test the
length of User.Properties("physicalDeliveryOfficeName"), or to test if it
exists/is initialized? If the length is zero, than you would get this
exception when trying to access
User.Properties("physicalDeliveryOfficeName")(0).

Lorenzo Minore & Patrick Baker
VB .Net Development

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> Greetings,
> I posted this in microsoft.public.adsi.general, but have had no bites on
it.
> Can anybody help me here?

> I have a program that reads data from our HR Database and updates AD with
> the appropriate info. The field I am having problems with is the
> physicalDeliveryOfficeName. If the field is empty, I get an
> ArgumentOutOfRangeException "Specified argument was out of the range of
> valid values. Parameter name: Index was out of range.  Must be
non-negative
> and less than the size of the collection." This is when it hits line 3 of
> the code below.

> The DataRow is working perfectly. For testing you can replace
r("Mailstop")
> with "Test"

> If I manually edit the Office field in AD and put anything in it, the code
> works fine and changes the field to the proper text.

> Here is the code I am playing with:

> [other code here to pull in hr info into a table and query ad for user
> objects]
> Dim r As DataRow
> If str_physicalDeliveryOfficeName <> r("Mailstop") Then
>     User.Properties("physicalDeliveryOfficeName")(0) = r("Mailstop")
>     b_Update_Needed = True
>     If strLogging = "verbose" Then
>         PrintLine(4, Now() & " Setting physicalDeliveryOfficeName to " &
> r("Mailstop"))
>     End If
> End If



Sun, 26 Dec 2004 04:52:57 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Creating NT User accounts using ADSI (WinNT:) within VB.Net

2. VB.Net - ADSI property name with dashes

3. ADSI and VB.NET

4. Filter ADSI objects in VB.net

5. ADSI and VB .Net

6. Using ADSI in Vb.NET

7. ADSI and VB.NET

8. ADSI code converstion to VB.net

9. VB.NET & CR.NET : User Defined Function

10. Difference between VB 6 & Vb.Net

11. VB & VB.NET

12. ADSI and .Net

 

 
Powered by phpBB® Forum Software