Objects: Procedures, Transactions, Work Panels, Web Panels
Languages: Java, .NET
Interfaces: Web, Win
LDAPClient data type is a new
GeneXus type that allows connecting to LDAP servers. It can be used to authenticate users or retrieve attributes under a specified context.
Server |
Specifies the LDAP connection server |
Port |
Specifies LDAP port |
AuthenticationMethod |
Specifies the authentication method: Simple, Anonymous, SASL |
User |
Specifies the user to be authenticated |
Password |
Specifies the user connection password |
Connect |
Connects to the LDAP server |
Disconnect |
Terminates the LDAP connection |
GetAttribute |
Retrieves attributes under a specified context |
Connect Creates the connection to the LDAP server at the specified host, port and using the specified authentication method. Optionally if user and password were specified they will be used to create the connection.
Returned Values
Numeric: 1 successfully connected, 0 couldn't connect to server.
Example
&ldapClient.Host = 'myServer'
&ldapClient.Port = 389
&ldapClient.AuthenticationMethod = 'simple'
&ldapClient.User = 'myUser'
&ldapClient.Password = 'myPassword'
&ret = &ldapClient.Connect()
Disconnect Terminates the connection with the server.
Example:
& ldapClient.Disconnect()
GetAttribute(String AttName, String context, Properties props)
Return the values of the "AttName" attribute defined by a context and a set of attributes.
Example:
&MatchAtts->Properties
&MatchAtts.set("uid", "John")
for &auxString in &ldapClient.GetAttribute("mail", "ou=People, o=myserver", &MatchAtts)
msg(&auxString)
endfor
See
Properties data type.
- Java: Information about SASL Authentication: http://java.sun.com/products/jndi/tutorial/ldap/security/sasl.html.
- Java: Information about LDAP Authentication here: http://java.sun.com/products/jndi/tutorial/ldap/security/auth.html
- Java: To use LDAPClient data type in Java, Sun Virtual Machine must be used.
- Java: Microsoft Virtual Machine doesn´t have native support for it. However it is possible to use LDAPClient (*just authenticate users) with Microsoft VM, if JNDI 1.1.2 is downloaded (JNDI 1.1.2 Class Libraries, LDAP Service Provider, 1.0.3) (http://java.sun.com/products/jndi/downloads/index.html). After that, jndi.jar, ldap.jar, providerutil.jar must be added to classpath. When using Microsoft VM it will be possible to authenticate users but it won't be possible to retrieve attributes.
- When specifying a context (when retrieving attributes for example) it is important to take into account that contexts are different depending on the directory tree structure and depending on the LDAP server. For example when using Netscape Server a possible context could be:
uid = John, ou = People, dc = myCompany, dc = com
When using Active Directory an example could be:
cn = John, ou = Users , dc = myCompany, dc = com
So it is very important to know that the context being used matches the server's directory tree structure in order to get correct results.