Sign in to follow this  
Followers 0
jakatak

Ldap Openldap

2 posts in this topic

Hi,

I am trying to run a script to read data from a LDAP unix based server. (like openldap)

I am trying with objcreate ...but i can't find the proper syntax.

Is anybody have done thate before ?

Thanks in advance,

Share this post


Link to post
Share on other sites



Hi,

I am trying to run a script to read data from a LDAP unix based server. (like openldap)

I am trying with objcreate ...but i can't find the proper syntax.

You'll find two examples below...

Sorry for the french comments and variable names, but you won't mind !

Is anybody have done thate before ?

Not before, but now ! :think:

o Find the users whose names contain the string in the variable "$ValeurRecherche"

; Parcours LDAP

Opt ("TrayIconDebug", 1)

Const $LDAPBaseDN = "ou=People,dc=***,dc=***"
Const $LDAPPort = "389"
Const $LDAPServeur = "***"
Const $LDAPUtilisateur = ""
Const $LDAPMdP = ""
Const $LDAPAdresse = $LDAPServeur & ":" & $LDAPPort & "/" & $LDAPBaseDN
$Liste = ""
$i = 0

;~ -----------------------------------------------------------------------

$ValeurRecherche = "toto"

;~ -----------------------------------------------------------------------

SplashTextOn ("Connexion LDAP", "Bind au serveur LDAP " & $LDAPServeur & " en cours...", 300, 50, 50, 50, 16)
$debut = TimerInit()
$ServeurLDAP = ObjGet ("LDAP://" & $LDAPAdresse)
$fin = TimerDiff($debut)

If @error Then
    MsgBox (4096, "Connexion LDAP", "Erreur de connexion à " & $LDAPServeur)
    Exit (-1)
EndIf

;~ Parcours de tous les utilisateurs du LDAP
For $Utilisateur In $ServeurLDAP
   If $Utilisateur.displayname = $ValeurRecherche Then
        $i = $i + 1
        SplashTextOn ("Connexion LDAP", "Bindé à " & $LDAPServeur & " en " & $fin / 1000 & " s" & @CRLF & @CRLF & $Utilisateur.displayName & " trouvé." & "N° " & $i, 300, 90, 50, 50, 16)
        $Liste = $Liste & $Utilisateur.displayName & @CRLF
   EndIf
Next

SplashOff ()

MsgBox (4096, "Toutes les entrées contenant " & $ValeurRecherche, $Liste)

o Display the name of the user given in the InputBox

; Recherche LDAP

Const $LDAPBaseDN = "ou=People,dc=***,dc=***"
Const $LDAPPort = "389"
Const $LDAPServeur = "***"
Const $LDAPUtilisateur = ""
Const $LDAPMdP = ""
Const $LDAPAdresse = "LDAP://" & $LDAPServeur & ":" & $LDAPPort & "/" & $LDAPBaseDN
$Liste = 0

$recherche = InputBox ("Nom", "Quel nom d'utilisateur voulez-vous rechercher dans le LDAP ?")

$Utilisateur = ObjGet ("LDAP://" & $LDAPServeur & ":" & $LDAPPort & "/uid=" & $recherche & "," & $LDAPBaseDN)

If @error Then
    MsgBox (4096, "Connexion LDAP", "Erreur de connexion à " & $LDAPServeur)
    Exit (-1)
EndIf

MsgBox (4096, "", $Utilisateur.displayName)

Cervélo Soloist 2004 & Cervélo P3C 2007

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0