LDAP & eDirectory

Posted on 2006-06-27
Last Modified: 2009-04-24
I need to authenticate users logging into our applications using their Novell user ID and password. There are some different teams where I work doing this but they are all Java teams and we are a VB team. I have be given the following information to use to connect to the test LDAP resource:

host is
port 389
base dn is o=abcauth
credentials cn=ldap_wed,ou=datacenter,o=abcauth
password is ldap9977

I was told I use this information to connect to the server. Then I query the system using the user’s name and password they supplied my application. I was told several of the Java teams here do it that way.

Can someone give me a simple version of how to do this using Using the information above to connect to the LDAP server. Then verify the user name and password entered into textboxes txtUser and txtPassword are correct for the Novell account the user of my application has entered?

Thank you for your help.
Question by:TheRoyalFalcon
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3

Accepted Solution

bman9111 earned 250 total points
ID: 16997752

Expert Comment

ID: 16997754

Author Comment

ID: 17001856
Thank you. I must confess I've read through both and I'm still unsure how to take the above and make it work. The Admin for our LDAP resource stated I must connect using the connection info above. Then find the user and verify their password. From both of these it would look like I would use the user name and password in the textboxes to connect?

I may just be reading all this wrong. I've barely slept. My son (less than 1), wife, and I are all stick. We were up all night and I am crawling (you know how it can be).

Could you help me a little further here (I'll even up the points). Could you, using the info from these links, show me how to plug in the information I listed above (the info our eDirectory-Novell LDAP resource gave me) if I wanted to verify a Novell userID="bobr" with a password="password" which were typed into the textboxes listed above?

I really need your help. THANK YOU!
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.


Expert Comment

ID: 17001909
Here is how I do it using Active Directory.  This function returns an email addy but it shows how to interface with ldap.

Public Property getEmail() As String
            getEmail = mEmail
        End Get
        Set(ByVal value As String)
            Dim input As String
            input = value
            Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://YourDirectory")
            Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)
            mySearcher.Filter = ("(&(objectClass=user)(name=" & input & "))")
            Dim resEnt As SearchResult
            For Each resEnt In mySearcher.FindAll()
                mEmail = resEnt.Properties("mail")(0).ToString
        End Set
    End Property

Expert Comment

ID: 17002086
not sure but try this....

Imports System
Imports System.Text
Imports System.Collections
Imports System.DirectoryServices
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()

        'This call is required by the Windows Form Designer.

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
            End If
        End If
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button
        Me.TextBox1 = New System.Windows.Forms.TextBox
        Me.TextBox2 = New System.Windows.Forms.TextBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.Button1.Location = New System.Drawing.Point(96, 144)
        Me.Button1.Name = "Button1"
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Button1"
        Me.TextBox1.Location = New System.Drawing.Point(120, 40)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.TabIndex = 1
        Me.TextBox1.Text = "TextBox1"
        Me.TextBox2.Location = New System.Drawing.Point(120, 80)
        Me.TextBox2.Name = "TextBox2"
        Me.TextBox2.TabIndex = 2
        Me.TextBox2.Text = "TextBox2"
        Me.Label1.Location = New System.Drawing.Point(0, 40)
        Me.Label1.Name = "Label1"
        Me.Label1.TabIndex = 3
        Me.Label1.Text = "username"
        Me.Label2.Location = New System.Drawing.Point(0, 80)
        Me.Label2.Name = "Label2"
        Me.Label2.TabIndex = 4
        Me.Label2.Text = "password"
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 266)
        Me.Name = "Form1"
        Me.Text = "Form1"

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        IsAuthenticated("", TextBox1.Text, TextBox2.Text)

    End Sub
    Public Function IsAuthenticated(ByVal domain As String, ByVal username As String, ByVal pwd As String) As Boolean
        Dim ldapinfo As String = "LDAP://" + ""
        Dim domainAndUsername As String = domain & "\" & username
        Dim entry As DirectoryEntry = New DirectoryEntry(ldapinfo, domainAndUsername, pwd)

            'Bind to the native AdsObject to force authentication.
            Dim obj As Object = entry.NativeObject
            Dim search As DirectorySearcher = New DirectorySearcher(entry)
            search.Filter = "(SAMAccountName=" & username & ")"
            'if gets here then the user exists
            MessageBox.Show("User exists")

        Catch ex As Exception
            MessageBox.Show("Error authenticating user. " & ex.Message)
        End Try

        Return True
    End Function

End Class

u will need to reference directoryservices.

Author Comment

ID: 17053736
Thank you both. These are very similar to different things I found when I went Googling at first. However none of them seemed to address how to tap into eDirectory just Active Directory. I did a bunch of reading on Java examples for eDirectory and then tried to modify what I had. It is basically the same code but what information is entered is different. Here is what I ended up doing.

<snip from above>
   host is
   port 389
   base dn is o=abcauth
   credentials cn=ldap_wed,ou=datacenter,o=abcauth
   password is ldap9977
<end snip>

'How to call the modified function
IsAuthenticated("389", "", " cn=ldap_wed,ou=datacenter,o=abcauth", " ldap9977")

Public Function IsAuthenticated(ByVal strPort As String, ByVal strDomain As String, ByVal strUsername As String, ByVal strPwd As String) As Boolean

        Dim strName As String
        Dim entry As DirectoryEntry = New DirectoryEntry("LDAP://" & strDomain & ":" & strPort)
        entry.Username = strUsername
        entry.Password = strPwd
        entry.AuthenticationType = AuthenticationTypes.None

        strName = entry.Name
        MsgBox("Welcome to '" + strName + "'")

        Catch ex As Exception
            MessageBox.Show("Error authenticating user. " & ex.Message)
        End Try
        Return TRUE
End Funciton

This isn’t how I’m going to ultimately implement it but for anyone looking for a to eDirectory this is the basics. Like I mentioned it’s really the same code floating around on the web for Active Directory but it shows how to enter the connection information properly for eDirectory which is what I was looking for. Hopefully this will help someone down the line.

Thank you both for your assistance. I appreciate it. This is bascially a spen off on bman9111 referenced examples, one of which also touched on the port. That had to be passed for it to work at my employer, so I am passing the points to him. But agian I appreciate you both taking the time to respond. Thanks agian.


Author Comment

ID: 17090563
BTW - For anyone looking for ieDirectory help here on this post there is one more thing I should have mentioned. On the user name parm "cn=" is the user Id. So say you need to auth user opRR123 it would read "cn=opRR123,ou=datacenter,o=abcauth". The rest of the information in the string is the pathing info where the accounts are located.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : All lightning effects with instructions : http://www.mediaf…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question