Directory Services


The ldap_conn_from_msg function returns the LDAP session handle (connection pointer) for a particular message.

LDAP* ldap_conn_from_msg(
  LDAP* PrimaryConn,
  LDAPMessage* res


[in] A pointer to the LDAP session handle of the message, if known. If the LDAP session handle for the message is unknown, then NULL may be passed for this parameter provided that the LDAP_OPT_REF_DEREF_CONN_PER_MSG session option had been previously set for the message session.
[in] The LDAP message queried. If NULL is passed for this parameter, then the function will respond with a NULL return value.

Return Values

The return value is the LDAP session handle (connection pointer) where the message originated from. This function returns NULL if the originating session has closed or if a NULL LDAPMessage pointer is passed to the function and the LDAP_OPT_REF_DEREF_CONN_PER_MSG session option was not previously set for the message session.


This function is used to identify the LDAP session handle associated with the specified LDAP message. It returns a valid LDAP session handle only if one of the following conditions are met:

If neither of these conditions are met, the function returns a NULL session handle.


Client: Included in Windows XP and Windows 2000 Professional.
Server: Included in Windows Server 2003 and Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension on Windows NT 4.0 SP6a and Windows 95/98/Me.
Unicode: Implemented as Unicode and ANSI versions on all platforms.
Header: Declared in Winldap.h.
Library: Use Wldap32.lib.

See Also

LDAP, LDAPMessage, structures, Establishing an LDAP Session, Functions, ldap_init, ldap_set_option, Return Values