Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Novell e-directory with VB

Status
Not open for further replies.

AndyH1

Programmer
Jan 11, 2004
350
GB
Iv'e been using the following code Visual Basic 6 code (see below) to access an Active Directory LDAP in the past with no problems. We have, however changed over to an Novell e-directory LDAP database and I can't get this code to work in a similar way on this LDAP database. Although its not giving an error, its not returning any values. Can anyone advise me on how to change the code to access a Non-microsoft LDAP such as e-directory? Is it possible and if so what modifications are required

desperately need a quick solution too this

Thanks in advance
Andy

' site number is not the real site here
Const LDAP_SERVERANDPORT = "LDAP://10.118.3.107:389"
Const LDAP_ENTRYPOINT = "LDAP://10.118.3.107:389/o=company/ou=users"
Const LDAP_USERNAME = "cn=username,ou=users,o=company"
Const LDAP_PASSWORD = "passwordxxx"

Private mstrChristianName As String
Private mstrSurname As String

Public Function GetUserDetails(ByVal strUser As String) As Boolean

Dim objConn As New Connection
Dim objCommand As New Command
Dim SQLStmt As String
Dim objConnStr As String
Dim rs As Recordset

Set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADSDSOObject"
objConn.Properties("Data Source") = LDAP_SERVERANDPORT
objConn.Properties("User ID") = LDAP_USERNAME
objConn.Properties("Password") = LDAP_PASSWORD
objConn.Properties("Encrypt Password") = False
objConn.Open "ADs Provider"

' Create the objConnection and command object.
Set objCommand = CreateObject("ADODB.Command")
Set objCommand.ActiveConnection = objConn
SQLStmt = "SELECT givenName FROM '" + LDAP_ENTRYPOINT + "' WHERE objectClass='companyUser' and cn='" + strUser + "'"

objCommand.CommandText = SQLStmt
Set rs = objCommand.Execute

If Not (rs.EOF And rs.BOF) Then
mstrChristianName = rs("givenName")
Else
GetUserDetails = False
End If
objConn.Close
Set objConn = Nothing
End Function

Public Property Get ChristianName() As String
ChristianName = mstrChristianName
End Property
 
Try to make a little detour. Query _only_ the adspath and get info from binding to the user object via the adspath.
[tt]
'etc etc
SQLStmt = "SELECT [blue]adspath[/blue] FROM '" + LDAP_ENTRYPOINT + "' WHERE objectClass='companyUser' and cn='" + strUser + "'"

objCommand.CommandText = SQLStmt
Set rs = objCommand.Execute

[blue]dim ouser as IADsUser[/blue]
If Not (rs.EOF And rs.BOF) Then
[blue]set ouser=getobject(rs("adspath").value)
ouser.getInfo
mstrChristianName = ouser.get("givenName")[/blue]
Else
GetUserDetails = False
End If
'etc etc
[/tt]
 
Thanks Tsuji,

When I try to compile (I'm running Visual Basic 6 in Win 2003 server) I'm getting

Compile error user defined type not defined on:

ouser As IADsUser

Iv'e found mention of IADsUser in vb.net but am not sure how I get/include the classes/objects for this item in visual basic 6.

Can you advise? Fraid I'm not really an very skilled on vb or vb.net yet

Thanks
Andy
 
I guess you've to bring the reference to active ds type library to the project in the vb6 ide. For ms ads, it is the "Active DS Type Library". You have to find out the corresponding one for eDirectory. Otherwise, simply use late binding and declare ouser as Object. (I am not user of eDirectory.)
 
Many thanks tsuji.

I managed to find this under references and ticked it and it compiled ok. However, am getting

ADODB.Fields error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.

/cf~ldaptestnew.asp, line 7

Will look around as you suggest for a corresponding Active DS Type Library for eDirectory

Seems its connection but not going to the right entry point? The structure of the LDAP hierarchy is

o = company
|
-------- ou = users
|
---------- cn = ABETTR
cn = ABRETT
cn = ADEADD

 
Haven't been able to find an Active DS Type Library for eDirectory. Can anyone advise. Stil getting no luck accessing an eDirectory LDAP.
 
Found a couple of references about differences between accessing a AD and a eDirectory. Not sure if they affect the coding

1. With eDirectory users must pass their name utilizing the distinguished name format otherwise will fail.

2. eDirectory uses ssl protocol to perform authentication task, whereas active directory utilizes the secure method.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top