apr_ldap_init.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
  2. * applicable.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /**
  17. * @file apr_ldap_init.h
  18. * @brief APR-UTIL LDAP ldap_init() functions
  19. */
  20. #ifndef APR_LDAP_INIT_H
  21. #define APR_LDAP_INIT_H
  22. /**
  23. * @defgroup APR_Util_LDAP LDAP
  24. * @ingroup APR_Util
  25. * @{
  26. */
  27. #include "apr_ldap.h"
  28. #if APR_HAS_LDAP
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif /* __cplusplus */
  32. /**
  33. * APR LDAP SSL Initialise function
  34. *
  35. * This function initialises SSL on the underlying LDAP toolkit
  36. * if this is necessary.
  37. *
  38. * If a CA certificate is provided, this is set, however the setting
  39. * of certificates via this method has been deprecated and will be removed in
  40. * APR v2.0.
  41. *
  42. * The apr_ldap_set_option() function with the APR_LDAP_OPT_TLS_CERT option
  43. * should be used instead to set certificates.
  44. *
  45. * If SSL support is not available on this platform, or a problem
  46. * was encountered while trying to set the certificate, the function
  47. * will return APR_EGENERAL. Further LDAP specific error information
  48. * can be found in result_err.
  49. * @param pool The pool to use
  50. * @param cert_auth_file The name of the certificate to use, can be NULL
  51. * @param cert_file_type The type of certificate specified. See the
  52. * apr_ldap_set_option() APR_LDAP_OPT_TLS_CERT option for details.
  53. * @param result_err The returned result
  54. */
  55. APU_DECLARE(int) apr_ldap_ssl_init(apr_pool_t *pool,
  56. const char *cert_auth_file,
  57. int cert_file_type,
  58. apr_ldap_err_t **result_err);
  59. /**
  60. * APR LDAP SSL De-Initialise function
  61. *
  62. * This function tears down any SSL certificate setup previously
  63. * set using apr_ldap_ssl_init(). It should be called to clean
  64. * up if a graceful restart of a service is attempted.
  65. * @todo currently we do not check whether apr_ldap_ssl_init()
  66. * has been called first - we probably should.
  67. */
  68. APU_DECLARE(int) apr_ldap_ssl_deinit(void);
  69. /**
  70. * APR LDAP initialise function
  71. *
  72. * This function is responsible for initialising an LDAP
  73. * connection in a toolkit independant way. It does the
  74. * job of ldap_init() from the C api.
  75. *
  76. * It handles both the SSL and non-SSL case, and attempts
  77. * to hide the complexity setup from the user. This function
  78. * assumes that any certificate setup necessary has already
  79. * been done.
  80. *
  81. * If SSL or STARTTLS needs to be enabled, and the underlying
  82. * toolkit supports it, the following values are accepted for
  83. * secure:
  84. *
  85. * APR_LDAP_NONE: No encryption
  86. * APR_LDAP_SSL: SSL encryption (ldaps://)
  87. * APR_LDAP_STARTTLS: Force STARTTLS on ldap://
  88. * @remark The Novell toolkit is only able to set the SSL mode via this
  89. * function. To work around this limitation, set the SSL mode here if no
  90. * per connection client certificates are present, otherwise set secure
  91. * APR_LDAP_NONE here, then set the per connection client certificates,
  92. * followed by setting the SSL mode via apr_ldap_set_option(). As Novell
  93. * does not support per connection client certificates, this problem is
  94. * worked around while still being compatible with other LDAP toolkits.
  95. * @param pool The pool to use
  96. * @param ldap The LDAP handle
  97. * @param hostname The name of the host to connect to. This can be either a
  98. * DNS name, or an IP address.
  99. * @param portno The port to connect to
  100. * @param secure The security mode to set
  101. * @param result_err The returned result
  102. */
  103. APU_DECLARE(int) apr_ldap_init(apr_pool_t *pool,
  104. LDAP **ldap,
  105. const char *hostname,
  106. int portno,
  107. int secure,
  108. apr_ldap_err_t **result_err);
  109. /**
  110. * APR LDAP info function
  111. *
  112. * This function returns a string describing the LDAP toolkit
  113. * currently in use. The string is placed inside result_err->reason.
  114. * @param pool The pool to use
  115. * @param result_err The returned result
  116. */
  117. APU_DECLARE(int) apr_ldap_info(apr_pool_t *pool,
  118. apr_ldap_err_t **result_err);
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif /* APR_HAS_LDAP */
  123. /** @} */
  124. #endif /* APR_LDAP_URL_H */