Active Directory/Search for a user: Difference between revisions
Content added Content deleted
(added D languange) |
(Haskell version) |
||
Line 88: | Line 88: | ||
"return cwel_is_credential_valid ((LPTSTR) $a_domain, (LPTSTR) $a_username, (LPTSTR) $a_password);" |
"return cwel_is_credential_valid ((LPTSTR) $a_domain, (LPTSTR) $a_username, (LPTSTR) $a_password);" |
||
end |
end |
||
</lang> |
|||
=={{header|Haskell}}== |
|||
Example uses the [https://hackage.haskell.org/package/ldap-client ldap-client]<tt> package: |
|||
<lang haskell> |
|||
{-# LANGUAGE OverloadedStrings #-} |
|||
module Main (main) where |
|||
import Data.Foldable (for_) |
|||
import qualified Data.Text.Encoding as Text (encodeUtf8) |
|||
import Ldap.Client (Attr(..), Filter(..)) |
|||
import qualified Ldap.Client as Ldap (Dn(..), Host(..), search, with, typesOnly) |
|||
main :: IO () |
|||
main = do |
|||
entries <- Ldap.with (Ldap.Plain "localhost") 389 $ \ldap -> |
|||
Ldap.search ldap (Ldap.Dn "o=example.com") (Ldap.typesOnly True) (Attr "uid" := Text.encodeUtf8 "user") [] |
|||
for_ entries $ \entry -> |
|||
print entry |
|||
</lang> |
</lang> |
||