Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
supr-ldap-integration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Swestore
supr-ldap-integration
Commits
3aac2d66
Commit
3aac2d66
authored
2 years ago
by
Einar Largenius
Browse files
Options
Downloads
Patches
Plain Diff
Use kadmin shell program instead of kadmin library
python-kadmin is not maintained anymore.
parent
17f3e832
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
supr_ldap_krb.py
+31
-15
31 additions, 15 deletions
supr_ldap_krb.py
with
31 additions
and
15 deletions
supr_ldap_krb.py
+
31
−
15
View file @
3aac2d66
"""
Main handler for supr and ldap connections.
"""
import
kadmin
from
textwrap
import
dedent
import
ldap
import
ldap.modlist
as
modlist
import
sys
import
supr
import
settings
import
subprocess
from
requests
import
ConnectionError
# requests.packages.urllib3.disable_warnings()
...
...
@@ -381,29 +381,45 @@ class SUPR_LDAP:
self
.
ERR_PERS_MAIL
+=
"
uidNumber ::
"
+
str
(
uidNumber
)
+
"
\t
Module :: addPerson
\n
"
self
.
err_pers_cnt
+=
1
# Function to add new person to Kerberos
def
addPersontoKerberos
(
self
,
m
,
attrsPerson
):
"""
Add a new person to Kerberos, if able
# Kadmin init or "login"
try
:
kadm
=
kadmin
.
init_with_keytab
(
settings
.
adminprincipal
,
settings
.
keytab
)
user
=
attrsPerson
[
'
uid
'
]
princ
=
kadm
.
getprinc
(
user
)
Uses external `kadmin` program.
if
(
princ
is
None
):
kadm
.
addprinc
(
user
,
None
)
:param m: Person to add (?)
:type m: Ldap person object (?)
:param attrsPerson: Person attributes to add to kerberos (?)
:type attrsPerson: Dictionary
:returns: None
"""
self
.
logger
.
info
(
"
Person with SUPR ID :: %s added to Kerberos -- %s
"
,
m
.
id
,
str
(
attrsPerson
[
'
uidNumber
'
]))
self
.
KRB_PERS_MAIL
+=
"
SUPR ID ::
"
+
str
(
m
.
id
)
+
"
\t
username(uid) ::
"
+
attrsPerson
[
'
uid
'
]
+
"
\t
Person Name ::
"
+
attrsPerson
[
'
cn
'
]
+
"
\n
"
try
:
# TODO: This one needs testing
result
=
subprocess
.
run
([
"
kadmin
"
,
"
-k
"
,
"
-t
"
,
settings
.
keytab
,
"
-p
"
,
settings
.
adminprincipal
,
"
addprinc
"
,
"
-randkey
"
,
attrsPerson
[
'
uid
'
]],
timeout
=
10
,
text
=
True
,
capture_output
=
True
)
for
line
in
result
.
stdout
.
splitlines
():
self
.
logger
.
info
(
line
)
for
line
in
result
.
stderr
.
splitlines
():
self
.
logger
.
warning
(
line
)
if
result
.
returncode
==
0
:
self
.
logger
.
info
(
"
Person with SUPR ID :: %s added to Kerberos -- %s
"
,
m
.
id
,
str
(
attrsPerson
[
'
uidNumber
'
]))
self
.
KRB_PERS_MAIL
+=
"
SUPR ID ::
"
+
str
(
m
.
id
)
+
"
\t
username(uid) ::
"
+
attrsPerson
[
'
uid
'
]
+
"
\t
Person Name ::
"
+
attrsPerson
[
'
cn
'
]
+
"
\n
"
self
.
krb_pers_cnt
+=
1
else
:
self
.
logger
.
info
(
"
Person with SUPR ID :: %s already added to Kerberos -- %s
"
,
m
.
id
,
str
(
attrsPerson
[
'
uidNumber
'
]))
sys
.
exit
(
1
)
except
Exception
as
e
:
self
.
logger
.
error
(
"
Error in addPersontoKerberos Module for %s :: %s
"
,
str
(
attrsPerson
[
'
uid
'
]),
e
)
self
.
ERR_PERS_MAIL
+=
"
uidNumber ::
"
+
str
(
attrsPerson
[
'
uid
'
])
+
"
\t
Module :: addPersontoKerberos
\n
"
except
Exception
as
e
xc
:
self
.
logger
.
error
(
"
Error in addPersontoKerberos Module for %s :: %s
"
,
str
(
attrsPerson
[
'
uid
'
]),
e
xc
)
self
.
ERR_PERS_MAIL
+=
"
uidNumber ::
"
+
str
(
attrsPerson
[
'
uid
'
])
+
"
\t
Module :: addPersontoKerberos
\n
"
self
.
err_pers_cnt
+=
1
def
updateDeletePersons
(
self
):
...
...
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