LDAP 0.6.6 → 0.6.7
raw patch · 3 files changed
+45/−8 lines, 3 filesnew-uploaderPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ LDAP.Init: ldapInitialize :: String -> IO LDAP
Files
- LDAP.cabal +9/−3
- LDAP/Init.hsc +31/−4
- LDAP/Search.hsc +5/−1
LDAP.cabal view
@@ -1,5 +1,5 @@ Name: LDAP-Version: 0.6.6+Version: 0.6.7 License: BSD3 Maintainer: John Goerzen <jgoerzen@complete.org> Author: John Goerzen@@ -41,7 +41,10 @@ GHC-Options: -O2 -- CC-Options: -Iglue- CC-Options: -DLDAP_DEPRECATED=1+ if os(openbsd)+ CC-Options: -DLDAP_X_PROXY_AUTHZ_FAILURE=LDAP_PROXY_AUTHZ_FAILURE+ else+ CC-Options: -DLDAP_DEPRECATED=1 Extensions: ForeignFunctionInterface, TypeSynonymInstances, EmptyDataDecls, ScopedTypeVariables, CPP @@ -52,7 +55,10 @@ Buildable: False Extra-Libraries: ldap Main-Is: runtests.hs- CC-Options: -DLDAP_DEPRECATED=1+ if os(openbsd)+ CC-Options: -DLDAP_X_PROXY_AUTHZ_FAILURE=LDAP_PROXY_AUTHZ_FAILURE+ else+ CC-Options: -DLDAP_DEPRECATED=1 Extensions: ForeignFunctionInterface, TypeSynonymInstances, EmptyDataDecls, ScopedTypeVariables, CPP Hs-Source-Dirs: testsrc, .
LDAP/Init.hsc view
@@ -22,11 +22,14 @@ module LDAP.Init(ldapOpen, ldapInit,+ ldapInitialize, ldapSimpleBind) where import Foreign.Ptr import Foreign.C.String+import Foreign.Marshal.Alloc+import Foreign.Storable import LDAP.Types import Foreign.C.Types import LDAP.Utils@@ -34,6 +37,12 @@ #include <ldap.h> ++ldapSetVersion3 :: LDAPPtr -> IO LDAPInt+ldapSetVersion3 cld =+ with ((#{const LDAP_VERSION3})::LDAPInt) $ \copt ->+ ldap_set_option cld #{const LDAP_OPT_PROTOCOL_VERSION} (castPtr copt)+ {- | Preferred way to initialize a LDAP connection. The default port is given in 'LDAP.Constants.ldapPort'. @@ -42,13 +51,11 @@ -> LDAPInt -- ^ Port -> IO LDAP -- ^ New LDAP Obj ldapInit host port =- withCString host (\cs ->- with ((#{const LDAP_VERSION3})::LDAPInt) (\copt ->+ withCString host $ \cs -> do cld <- cldap_init cs port rv <- fromLDAPPtr "ldapInit" (return cld)- ldap_set_option cld #{const LDAP_OPT_PROTOCOL_VERSION} (castPtr copt)+ ldapSetVersion3 cld return rv- )) {- | Like 'ldapInit', but establish network connection immediately. -} ldapOpen :: String -- ^ Host@@ -58,6 +65,23 @@ withCString host (\cs -> fromLDAPPtr "ldapOpen" $ cldap_open cs port) +{- | Like 'ldapInit', but accepts a URI (or whitespace/comma separated+list of URIs) which can contain a schema, a host and a port. Besides+ldap, valid schemas are ldaps (LDAP over TLS), ldapi (LDAP over IPC),+and cldap (connectionless LDAP). -}+ldapInitialize :: String -- ^ URI+ -> IO LDAP -- ^ New LDAP Obj+ldapInitialize uri =+ withCString uri $ \cs ->+ alloca $ \pp -> do+ r <- ldap_initialize pp cs+ p <- peek pp+ ldap <- fromLDAPPtr "ldapInitialize" (return p)+ _ <- checkLE "ldapInitialize" ldap (return r)+ ldapSetVersion3 p+ return ldap++ {- | Bind to the remote server. -} ldapSimpleBind :: LDAP -- ^ LDAP Object -> String -- ^ DN (Distinguished Name)@@ -78,6 +102,9 @@ foreign import ccall unsafe "ldap.h ldap_open" cldap_open :: CString -> CInt -> IO LDAPPtr++foreign import ccall unsafe "ldap.h ldap_initialize"+ ldap_initialize :: Ptr LDAPPtr -> CString -> IO LDAPInt foreign import ccall unsafe "ldap.h ldap_simple_bind_s" ldap_simple_bind_s :: LDAPPtr -> CString -> CString -> IO LDAPInt
LDAP/Search.hsc view
@@ -129,7 +129,11 @@ getvalues cld clm attr = withCString attr (\cattr -> do berarr <- ldap_get_values_len cld clm cattr- finally (procberarr berarr) (ldap_value_free_len berarr)+ if berarr == nullPtr+ -- Work around bug between Fedora DS and OpenLDAP (ldapvi+ -- does the same thing)+ then return []+ else finally (procberarr berarr) (ldap_value_free_len berarr) ) procberarr :: Ptr (Ptr Berval) -> IO [String]