Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b32d420a
Commit
b32d420a
authored
Jan 25, 2019
by
Leonard Gram
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ldap: refactoring.
parent
21a1507c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
13 deletions
+16
-13
pkg/login/ldap.go
+16
-13
No files found.
pkg/login/ldap.go
View file @
b32d420a
...
@@ -273,25 +273,28 @@ func (a *ldapAuther) initialBind(username, userPassword string) error {
...
@@ -273,25 +273,28 @@ func (a *ldapAuther) initialBind(username, userPassword string) error {
return
nil
return
nil
}
}
func
appendIfNotEmpty
(
slice
[]
string
,
values
...
string
)
[]
string
{
for
_
,
v
:=
range
values
{
if
v
!=
""
{
slice
=
append
(
slice
,
v
)
}
}
return
slice
}
func
(
a
*
ldapAuther
)
searchForUser
(
username
string
)
(
*
LdapUserInfo
,
error
)
{
func
(
a
*
ldapAuther
)
searchForUser
(
username
string
)
(
*
LdapUserInfo
,
error
)
{
var
searchResult
*
ldap
.
SearchResult
var
searchResult
*
ldap
.
SearchResult
var
err
error
var
err
error
for
_
,
searchBase
:=
range
a
.
server
.
SearchBaseDNs
{
for
_
,
searchBase
:=
range
a
.
server
.
SearchBaseDNs
{
attributes
:=
make
([]
string
,
0
)
attributes
:=
make
([]
string
,
0
)
inputs
:=
a
.
server
.
Attr
appendIfNotEmpty
:=
func
(
slice
[]
string
,
attr
string
)
[]
string
{
attributes
=
appendIfNotEmpty
(
attributes
,
if
attr
==
""
{
inputs
.
Username
,
return
slice
inputs
.
Surname
,
}
inputs
.
Email
,
return
append
(
slice
,
attr
)
inputs
.
Name
,
}
inputs
.
MemberOf
)
attributes
=
appendIfNotEmpty
(
attributes
,
a
.
server
.
Attr
.
Username
)
attributes
=
appendIfNotEmpty
(
attributes
,
a
.
server
.
Attr
.
Surname
)
attributes
=
appendIfNotEmpty
(
attributes
,
a
.
server
.
Attr
.
Email
)
attributes
=
appendIfNotEmpty
(
attributes
,
a
.
server
.
Attr
.
Name
)
attributes
=
appendIfNotEmpty
(
attributes
,
a
.
server
.
Attr
.
MemberOf
)
searchReq
:=
ldap
.
SearchRequest
{
searchReq
:=
ldap
.
SearchRequest
{
BaseDN
:
searchBase
,
BaseDN
:
searchBase
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment