Help Needed with Directory Services

Last post 05-08-2008 5:15 PM by johram. 1 replies.

Sort Posts:

  • Help Needed with Directory Services

    05-08-2008, 2:28 PM
    • Loading...
    • Skip_Frog
    • Joined on 12-20-2006, 5:30 PM
    • Posts 168

    Hi All,

    I am using the below to retrieve the user name from log in credentials. All works good BUT I have to supply a valid user and password for it to work. How do I do this without having to supply a hardcoded user name and password? Thanks

    Function GetUserName(ByVal userN As String) As String
            Dim
    ADEntry As New System.DirectoryServices.DirectoryEntry("WinNT://" & userN)

            ADEntry.Username = "xxxxx" 'This is the problem
            ADEntry.Password = "xxxxx"

            For Each strkey As String In ADEntry.Properties.PropertyNames
                Dim strstuff As String = ADEntry.Properties(strkey).Value.ToString
            Next

            Try
                Return
    ADEntry.Properties("FullName").Value
            Catch
                Return
    "Employee Id not found"
            End Try

        End Function

     
  • Re: Help Needed with Directory Services

    05-08-2008, 5:15 PM
    • Loading...
    • johram
    • Joined on 06-13-2006, 6:36 AM
    • Sweden
    • Posts 1,865
    • Moderator

    Please read Ryan Dunn's excellent post "Common System.DirectoryServices Issues and Solutions" in which he explains the different method available for doing exactly what you want :)

    If this post was useful to you, please mark it as answer. Thank you!
Page 1 of 1 (2 items)