Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rocket.Chat
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
RocketChat
Rocket.Chat
Commits
efe01c6e
Commit
efe01c6e
authored
9 years ago
by
George Secrieru
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring - added support for dynamic field mapping
parent
2a3bb638
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
i18n/en.i18n.json
+1
-0
1 addition, 0 deletions
i18n/en.i18n.json
i18n/pt.i18n.json
+1
-0
1 addition, 0 deletions
i18n/pt.i18n.json
packages/rocketchat-ldap/ldap_server.js
+37
-17
37 additions, 17 deletions
packages/rocketchat-ldap/ldap_server.js
with
39 additions
and
17 deletions
i18n/en.i18n.json
+
1
−
0
View file @
efe01c6e
...
...
@@ -186,6 +186,7 @@
"LDAP_Enable"
:
"Enable LDAP"
,
"LDAP_Port"
:
"LDAP Port"
,
"LDAP_Sync_User_Data"
:
"Keep user data in sync with server"
,
"LDAP_Sync_User_Data_FieldMap"
:
"User data field map"
,
"LDAP_Url"
:
"LDAP URL"
,
"Leave_room"
:
"Leave room"
,
"line"
:
"line"
,
...
...
This diff is collapsed.
Click to expand it.
i18n/pt.i18n.json
+
1
−
0
View file @
efe01c6e
...
...
@@ -172,6 +172,7 @@
"LDAP_Dn"
:
"DN LDAP"
,
"LDAP_Port"
:
"Porta LDAP"
,
"LDAP_Sync_User_Data"
:
"Manter dados dos usuários sincronizados"
,
"LDAP_Sync_User_Data_FieldMap"
:
"Mapeamento de campos do usuário"
,
"LDAP_Url"
:
"URL LDAP"
,
"Leave_room"
:
"Sair da sala"
,
"line"
:
"linha"
,
...
...
This diff is collapsed.
Click to expand it.
packages/rocketchat-ldap/ldap_server.js
+
37
−
17
View file @
efe01c6e
...
...
@@ -3,7 +3,7 @@ Future = Npm.require('fibers/future');
var
slug
=
function
(
text
)
{
text
=
slugify
(
text
,
'
.
'
);
return
text
.
replace
(
/
[^
0-9a-z-_.
]
/g
,
''
);
}
}
;
// At a minimum, set up LDAP_DEFAULTS.url and .dn according to
// your needs. url should appear as "ldap://your.url.here"
...
...
@@ -86,7 +86,7 @@ LDAP.prototype.ldapCheck = function(options) {
var
bind
=
function
(
dn
)
{
dn
=
dn
.
replace
(
/#{username}/g
,
options
.
username
);
console
.
log
(
'
Attempt to bind
'
,
dn
)
console
.
log
(
'
Attempt to bind
'
,
dn
)
;
//Attempt to bind to ldap server with provided info
client
.
bind
(
dn
,
options
.
ldapPass
,
function
(
err
)
{
try
{
...
...
@@ -127,7 +127,7 @@ LDAP.prototype.ldapCheck = function(options) {
});
}
});
}
}
;
if
(
LDAP_DEFAULTS
.
bindSearch
&&
LDAP_DEFAULTS
.
bindSearch
.
trim
()
!=
''
)
{
try
{
...
...
@@ -290,29 +290,49 @@ Accounts.registerLoginHandler("ldap", function(loginRequest) {
throw
new
Meteor
.
Error
(
"
LDAP-login-error
"
,
"
LDAP Authentication succeded, but no user exists in Mongo. Either create a user for this email or set LDAP_DEFAULTS.createNewUser to true
"
);
}
if
(
userId
&&
RocketChat
.
settings
.
get
(
'
LDAP_Sync_User_Data
'
))
{
// LDAP sync data logic
syncUserData
=
RocketChat
.
settings
.
get
(
'
LDAP_Sync_User_Data
'
);
syncUserDataFieldMap
=
RocketChat
.
settings
.
get
(
'
LDAP_Sync_User_Data_FieldMap
'
).
trim
();
if
(
userId
&&
syncUserData
&&
syncUserDataFieldMap
)
{
userData
=
{};
if
(
ldap
Response
.
searchResults
.
hasOwnProperty
(
'
mail
'
))
{
fie
ld
M
ap
=
JSON
.
parse
(
syncUserDataFieldMap
);
if
(
'
object
'
==
typeof
ldapResponse
.
searchResults
.
mail
)
{
userData
.
emails
=
_
.
map
(
ldapResponse
.
searchResults
.
mail
,
function
(
item
)
{
return
{
address
:
item
,
verified
:
true
};
});
}
else
{
userData
.
emails
=
[{
address
:
ldapResponse
.
searchResults
.
mail
,
verified
:
true
}];
emailList
=
[];
_
.
map
(
fieldMap
,
function
(
userField
,
ldapField
)
{
if
(
!
ldapResponse
.
searchResults
.
hasOwnProperty
(
ldapField
))
{
return
;
}
}
if
(
ldapResponse
.
searchResults
.
hasOwnProperty
(
'
name
'
))
{
userData
.
name
=
ldapResponse
.
searchResults
.
givenName
;
// restrict field mapping to a known list of fields
switch
(
userField
)
{
case
'
email
'
:
if
(
'
object
'
==
typeof
ldapResponse
.
searchResults
[
ldapField
])
{
_
.
map
(
ldapResponse
.
searchResults
[
ldapField
],
function
(
item
)
{
emailList
.
push
({
address
:
item
,
verified
:
true
});
});
}
else
{
emailList
.
push
({
address
:
ldapResponse
.
searchResults
[
ldapField
],
verified
:
true
});
}
break
;
case
'
name
'
:
userData
.
name
=
ldapResponse
.
searchResults
[
ldapField
];
break
;
default
:
break
;
}
});
if
(
emailList
.
length
)
{
userData
.
emails
=
emailList
;
}
if
(
_
.
size
(
userData
))
{
Meteor
.
users
.
update
(
userId
,
{
$set
:
userData
});
}
}
return
{
...
...
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