Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-LDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-LDAP
Commits
2dee6c93
Verified
Commit
2dee6c93
authored
5 years ago
by
Nik | Klampfradler
Browse files
Options
Downloads
Patches
Plain Diff
Use cached attrs for user loading
parent
24a64251
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!4
Resolve "Mass import of users"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/apps/ldap/util/ldap_sync.py
+4
-5
4 additions, 5 deletions
aleksis/apps/ldap/util/ldap_sync.py
with
4 additions
and
5 deletions
aleksis/apps/ldap/util/ldap_sync.py
+
4
−
5
View file @
2dee6c93
...
...
@@ -135,7 +135,7 @@ def ldap_sync_user_on_login(sender, instance, created, **kwargs):
@transaction.atomic
def
ldap_sync_from_user
(
user
):
def
ldap_sync_from_user
(
user
,
attrs
):
"""
Synchronise person information from a User object (with ldap_user) to Django
"""
Person
=
apps
.
get_model
(
"
core
"
,
"
Person
"
)
...
...
@@ -174,8 +174,8 @@ def ldap_sync_from_user(user):
# Try sync if constance setting for this field is non-empty
ldap_field
=
getattr
(
config
,
setting_name
,
""
).
lower
()
if
ldap_field
and
ldap_field
in
user
.
ldap_user
.
attrs
.
data
:
value
=
user
.
ldap_user
.
attrs
.
data
[
ldap_field
][
0
]
if
ldap_field
and
ldap_field
in
attrs
:
value
=
attrs
[
ldap_field
][
0
]
# Apply regex replace from config
patterns
=
getattr
(
config
,
setting_name
+
"
_RE
"
,
""
)
...
...
@@ -282,10 +282,9 @@ def mass_ldap_import():
# Find out whether the User object would be created, but do not save
user
,
created
=
backend
.
get_or_build_user
(
uid
,
ldap_user
)
user
.
ldap_user
=
ldap_user
if
created
or
config
.
LDAP_SYNC_ON_UPDATE
:
logger
.
info
(
"
Will %s user %s in Django
"
%
(
"
create
"
if
created
else
"
update
"
,
uid
))
person
=
ldap_sync_from_user
(
user
)
person
=
ldap_sync_from_user
(
user
,
attrs
)
logger
.
info
(
"
Successfully imported user %s
"
%
uid
)
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