Results 1 to 10 of 10

Thread: Solved] retrieve information from Active Directory

Hybrid View

  1. #1

    Thread Starter
    Lively Member darktown's Avatar
    Join Date
    Apr 2006
    Posts
    85

    Re: [2005] retrieve information from Active Directory

    found a nice article and it works: http://forums.asp.net/thread/1309113.aspx
    But i also want to be able to edit the field, there is a link but it's all in C-sharp and i don't understand it.

    could someone explain & intergrate it in my code :

    Code:
    Dim filter As String = String.Format("(&(objectClass=user)(objectCategory=person)(sAMAccountName={0}))", Environment.UserName)
            Dim entry As New DirectoryEntry("LDAP://verelst.nw", "jkhadmin", "Tidus05")
            Dim searcher As New DirectorySearcher(entry, filter, New String() {"displayName", "streetAddress", "l", "st", "postalCode", "physicalDeliveryOfficeName", "mail"})
            Dim fullName As String = ""
    
            Try
    
                Dim result As SearchResult = searcher.FindOne()
    
                If Not IsNothing(result) Then
    
                    If (result.Properties.Contains("displayName")) Then
                        lblName.Text = "Name"
                        txtCity.Text = result.Properties("displayName")(0).ToString
                    End If
    
                    If (result.Properties.Contains("streetAddress")) Then
                        lblAddress.Text = result.Properties("streetAddress")(0)
                    End If
    
                    If (result.Properties.Contains("l")) Then
                        lblcity.Text = result.Properties("l")(0)
                    End If
    
                    If (result.Properties.Contains("st")) Then
                        lblstate.Text = result.Properties("st")(0)
                    End If
    
                    If (result.Properties.Contains("postalCode")) Then
                        lblzip.Text = result.Properties("postalCode")(0)
                    End If
    
                    If (result.Properties.Contains("physicalDeliveryOfficeName")) Then
                        lblphone.Text = result.Properties("physicalDeliveryOfficeName")(0)
                    End If
    
                    If (result.Properties.Contains("mail")) Then
                        lblDesc.Text = result.Properties("mail")(0)
                    End If
                End If
    
            Catch
    
                Throw
    
            Finally
    
                If Not (entry Is Nothing) Then
    
                    entry.Dispose()
    
                End If
    
                If Not (searcher Is Nothing) Then
                    searcher.Dispose()
                End If
            End Try
    There is an easy way, there is a hard way and there is My way of doing things!

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: [2005] retrieve information from Active Directory

    There are lot of converteres over there which can convert C# code in VB.NET and vice versa. Try one of those.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width