Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gdd-sigma-poc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Guillaume WANG
gdd-sigma-poc
Commits
dadf6e72
Commit
dadf6e72
authored
7 years ago
by
Anatole ROMON
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of gitlab.binets.fr:br/sigma-backend
parents
0d5305c6
3ed63393
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/ldap/ldap_data.js
+15
-14
15 additions, 14 deletions
src/ldap/ldap_data.js
with
15 additions
and
14 deletions
src/ldap/ldap_data.js
+
15
−
14
View file @
dadf6e72
...
@@ -3,23 +3,24 @@
...
@@ -3,23 +3,24 @@
* @author hawkspar
* @author hawkspar
*/
*/
/* Ne pas hésiter à repasser en synthaxe ES5... Plus simple pour tester en solo avec node directement
/* Ne pas hésiter à repasser en synthaxe ES5... Plus simple pour tester en solo avec node directement
*/
import
ldap
from
'
ldapjs
'
;
import
ldap
from
'
ldapjs
'
;
import
fs
from
'
fs
'
;
import
fs
from
'
fs
'
;
import ldapEscape from 'ldap-escape'; */
import
ldapEscape
from
'
ldap-escape
'
;
import
path
from
'
path
'
;
/*
*/
var
ldap
=
require
(
'
ldapjs
'
);
/*var ldap = require('ldapjs');
var fs = require('fs');
var fs = require('fs');
var ldapEscape = require('ldap-escape');
var ldapEscape = require('ldap-escape');
var
path
=
require
(
'
path
'
);
var path = require('path');
*/
// Important ; permet de vérifier que l'utilisateur reste connecté.
// Important ; permet de vérifier que l'utilisateur reste connecté.
var
ensureLoggedin
=
require
(
'
connect-ensure-login
'
).
ensureLoggedIn
;
var
ensureLoggedin
=
require
(
'
connect-ensure-login
'
).
ensureLoggedIn
;
// Point central ; tous les champs de la BDD sont 'cachés' dans config.json et pas visibles directement
// Point central ; tous les champs de la BDD sont 'cachés' dans config.json et pas visibles directement
let
configPath
=
path
.
resolve
(
'
./
'
,
'
ldap_config.json
'
);
var
configPath
=
path
.
resolve
(
'
./
'
,
'
ldap_config.json
'
);
console
.
log
(
'
LDAP configuration loaded from
'
,
configPath
);
console
.
log
(
'
LDAP configuration loaded from
'
,
configPath
);
let
config
=
JSON
.
parse
(
fs
.
readFileSync
(
configPath
,
'
utf8
'
));
var
config
=
JSON
.
parse
(
fs
.
readFileSync
(
configPath
,
'
utf8
'
));
// Connection au serveur LDAP avec des temps de timeout arbitraires
// Connection au serveur LDAP avec des temps de timeout arbitraires
var
client
=
ldap
.
createClient
({
url
:
config
.
ldap
.
server
});
var
client
=
ldap
.
createClient
({
url
:
config
.
ldap
.
server
});
...
@@ -43,7 +44,7 @@ function requeteLDAP(base, filter, filter_dic, attributes) {
...
@@ -43,7 +44,7 @@ function requeteLDAP(base, filter, filter_dic, attributes) {
// A terme mettre id du type qui se connecte (permet de pas avoir trop de demandes trop rapides)
// A terme mettre id du type qui se connecte (permet de pas avoir trop de demandes trop rapides)
client
.
bind
(
config
.
connexion
.
dn
,
config
.
connexion
.
passwd
,
(
err
,
res
)
=>
{});
client
.
bind
(
config
.
connexion
.
dn
,
config
.
connexion
.
passwd
,
(
err
,
res
)
=>
{});
var
vals
=
[];
let
vals
=
[];
// Interrogation LDAP selon configuration du dic
// Interrogation LDAP selon configuration du dic
client
.
search
(
base
,
{
client
.
search
(
base
,
{
"
scope
"
:
"
sub
"
,
"
scope
"
:
"
sub
"
,
...
@@ -151,8 +152,8 @@ function rens(uid) {
...
@@ -151,8 +152,8 @@ function rens(uid) {
*/
*/
function
idTOL
(
c0
=
""
,
c1
=
""
,
c2
=
""
,
c3
=
""
,
c4
=
""
,
c5
=
""
,
c6
=
""
,
c7
=
""
,
c8
=
""
,
c9
=
""
,
c10
=
""
,
c11
=
""
,
c12
=
""
)
{
function
idTOL
(
c0
=
""
,
c1
=
""
,
c2
=
""
,
c3
=
""
,
c4
=
""
,
c5
=
""
,
c6
=
""
,
c7
=
""
,
c8
=
""
,
c9
=
""
,
c10
=
""
,
c11
=
""
,
c12
=
""
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
filter
=
""
;
let
filter
=
""
;
var
filter_dic
=
{};
let
filter_dic
=
{};
// Iteration pour chaque champ, alourdissement du filtre selon des trucs prédéfini dans config.json encore
// Iteration pour chaque champ, alourdissement du filtre selon des trucs prédéfini dans config.json encore
config
.
search_attributes_tol
.
forEach
((
element
,
index
,
list
)
=>
{
config
.
search_attributes_tol
.
forEach
((
element
,
index
,
list
)
=>
{
if
(
eval
(
"
c
"
+
index
)
!=
''
)
{
// Si il y a qque chose à chercher pour ce filtre
if
(
eval
(
"
c
"
+
index
)
!=
''
)
{
// Si il y a qque chose à chercher pour ce filtre
...
@@ -193,8 +194,8 @@ function TOL(c0="", c1="", c2="", c3="", c4="", c5="", c6="", c7="", c8="", c9="
...
@@ -193,8 +194,8 @@ function TOL(c0="", c1="", c2="", c3="", c4="", c5="", c6="", c7="", c8="", c9="
// Pas nécessaire mais bien
// Pas nécessaire mais bien
client
.
bind
(
config
.
connexion
.
dn
,
config
.
connexion
.
passwd
,
(
err
,
res
)
=>
{});
client
.
bind
(
config
.
connexion
.
dn
,
config
.
connexion
.
passwd
,
(
err
,
res
)
=>
{});
var
filter
=
""
;
let
filter
=
""
;
var
dic
=
{};
let
dic
=
{};
// Iteration pour chaque champ, alourdissement du filtre selon des trucs prédéfini dans config.json encore
// Iteration pour chaque champ, alourdissement du filtre selon des trucs prédéfini dans config.json encore
config
.
ldap_data_tol
.
searchFilterAttributes
.
forEach
((
element
,
index
,
list
)
=>
{
config
.
ldap_data_tol
.
searchFilterAttributes
.
forEach
((
element
,
index
,
list
)
=>
{
if
(
eval
(
"
c
"
+
index
.
toString
())
!=
''
)
{
// Si il y a qque chose à chercher pour ce filtre
if
(
eval
(
"
c
"
+
index
.
toString
())
!=
''
)
{
// Si il y a qque chose à chercher pour ce filtre
...
@@ -248,7 +249,7 @@ function TOL(c0="", c1="", c2="", c3="", c4="", c5="", c6="", c7="", c8="", c9="
...
@@ -248,7 +249,7 @@ function TOL(c0="", c1="", c2="", c3="", c4="", c5="", c6="", c7="", c8="", c9="
//idTOL("","","","","","","bda","","","","","","").then((caList) => { console.log(caList); });
//idTOL("","","","","","","bda","","","","","","").then((caList) => { console.log(caList); });
//TOL("","","","","","","faerix","","","","","","").then((caList) => { console.log(caList); });
//TOL("","","","","","","faerix","","","","","","").then((caList) => { console.log(caList); });
/* Partage pour le reste du monde ; même remarque synthaxe que pour l'import
/* Partage pour le reste du monde ; même remarque synthaxe que pour l'import
*/
export { listGroups, listMembers, TOL };
*/
export
{
listGroups
,
listMembers
,
TOL
};
module
.
exports
=
{
listGroups
,
listMembers
,
TOL
};
/*
*/
/*
module.exports ={ listGroups, listMembers, TOL };*/
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment