help how to pull information from AD RRS feed

  • General discussion

  • Hi Guys,

    Im trying to pull information from AD but somehow its giving me a result only in this property

                   ' date of account created
                    Console.WriteLine(GetProperty(sResultSet, "whenCreated"))
                    ' date of account changed
                    Console.WriteLine(GetProperty(sResultSet, "whenChanged"))

    the result is this


    Can you check whats wrong with my query or in the code? Thanks.

    Sub Main()
                Dim entry As DirectoryEntry = New DirectoryEntry("LDAP://DC=porto,DC=ot,DC=org")
                Dim dSearch As DirectorySearcher = New DirectorySearcher(entry)
                dSearch.Filter = "(objectClass=*)"
                For Each sResultSet As SearchResult In dSearch.FindAll()
                    ' Login Name
                    Console.WriteLine(GetProperty(sResultSet, "cn"))
                    ' First Name
                    Console.WriteLine(GetProperty(sResultSet, "givenName"))
                    ' Middle Initials
                    Console.WriteLine(GetProperty(sResultSet, "initials"))
                    ' Last Name
                    Console.WriteLine(GetProperty(sResultSet, "sn"))
                    ' Address
                    Dim tempAddress As String = GetProperty(sResultSet, "homePostalAddress")
                    If tempAddress <> String.Empty Then
                        Dim addressArray As String() = tempAddress.Split(";"c)
                        Dim taddr1 As String, taddr2 As String
                        taddr1 = addressArray(0)
                        taddr2 = addressArray(1)
                    End If
                    ' title
                    Console.WriteLine(GetProperty(sResultSet, "title"))
                    ' company
                    Console.WriteLine(GetProperty(sResultSet, "company"))
                    Console.WriteLine(GetProperty(sResultSet, "st"))
                    Console.WriteLine(GetProperty(sResultSet, "l"))
                    Console.WriteLine(GetProperty(sResultSet, "co"))
                    'postal code
                    Console.WriteLine(GetProperty(sResultSet, "postalCode"))
                    ' telephonenumber
                    Console.WriteLine(GetProperty(sResultSet, "telephoneNumber"))
                    Console.WriteLine(GetProperty(sResultSet, "otherTelephone"))
                    Console.WriteLine(GetProperty(sResultSet, "facsimileTelephoneNumber"))
                    ' email address
                    Console.WriteLine(GetProperty(sResultSet, "mail"))
                    ' Challenge Question
                    Console.WriteLine(GetProperty(sResultSet, "extensionAttribute1"))
                    ' Challenge Response
                    Console.WriteLine(GetProperty(sResultSet, "extensionAttribute2"))
                    'Member Company
                    Console.WriteLine(GetProperty(sResultSet, "extensionAttribute3"))
                    ' Company Relation ship Exits
                    Console.WriteLine(GetProperty(sResultSet, "extensionAttribute4"))
                    Console.WriteLine(GetProperty(sResultSet, "extensionAttribute5"))
                    ' Assigned Sales Person
                    Console.WriteLine(GetProperty(sResultSet, "extensionAttribute6"))
                    ' Accept T and C
                    Console.WriteLine(GetProperty(sResultSet, "extensionAttribute7"))
                    ' jobs
                    Console.WriteLine(GetProperty(sResultSet, "extensionAttribute8"))
                    Dim tEmail As [String] = GetProperty(sResultSet, "extensionAttribute9")
                    ' email over night
                    If tEmail <> String.Empty Then
                        Dim em1 As String, em2 As String, em3 As String
                        Dim emailArray As String() = tEmail.Split(";"c)
                        em1 = emailArray(0)
                        em2 = emailArray(1)
                        em3 = emailArray(2)
                        Console.WriteLine(em1 & em2 & em3)
                    End If
                    ' email daily emerging market
                    Console.WriteLine(GetProperty(sResultSet, "extensionAttribute10"))
                    ' email daily corporate market
                    Console.WriteLine(GetProperty(sResultSet, "extensionAttribute11"))
                    ' AssetMgt Range
                    Console.WriteLine(GetProperty(sResultSet, "extensionAttribute12"))
                    ' date of account created
                    Console.WriteLine(GetProperty(sResultSet, "whenCreated"))
                    ' date of account changed
                    Console.WriteLine(GetProperty(sResultSet, "whenChanged"))
            Catch ex As Exception
            End Try
        End Sub
        Public Function GetProperty(ByVal searchResult As SearchResult, ByVal PropertyName As String)
            If searchResult.Properties.Contains(PropertyName) Then
                Return searchResult.Properties(PropertyName(0).ToString)
                Return String.Empty
            End If
        End Function


    Wednesday, March 14, 2012 9:26 AM