add accounts for login/logout
This commit is contained in:
0
fet2020/accounts/__init__.py
Normal file
0
fet2020/accounts/__init__.py
Normal file
3
fet2020/accounts/admin.py
Normal file
3
fet2020/accounts/admin.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
5
fet2020/accounts/apps.py
Normal file
5
fet2020/accounts/apps.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class AccountsConfig(AppConfig):
|
||||||
|
name = 'accounts'
|
||||||
3
fet2020/accounts/models.py
Normal file
3
fet2020/accounts/models.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
3
fet2020/accounts/tests.py
Normal file
3
fet2020/accounts/tests.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
40
fet2020/accounts/views.py
Normal file
40
fet2020/accounts/views.py
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
##############################
|
||||||
|
import ldap3
|
||||||
|
from pprint import pprint
|
||||||
|
|
||||||
|
|
||||||
|
server_uri = 'ipa.demo1.freeipa.org'
|
||||||
|
search_base = 'ou=users,dc=example,dc=com'
|
||||||
|
search_filter = '(uid=rob)'
|
||||||
|
attrs = ['*']
|
||||||
|
|
||||||
|
# Using ldap3
|
||||||
|
server = ldap3.Server(server_uri, get_info='ALL')
|
||||||
|
with ldap3.Connection(server, auto_bind=True) as conn:
|
||||||
|
conn.search(search_base, search_filter, attributes=attrs)
|
||||||
|
pprint(conn.entries)
|
||||||
|
pprint(server.info)
|
||||||
|
|
||||||
|
# [DN: uid=rob,ou=users,dc=example,dc=com
|
||||||
|
# cn: Rob McBroom
|
||||||
|
# displayName: Rob McBroom
|
||||||
|
# gidNumber: 99999
|
||||||
|
# givenName: Rob
|
||||||
|
# homeDirectory: /home/rob
|
||||||
|
# homePhone: 800-555-1212
|
||||||
|
# host: *
|
||||||
|
# loginShell: /bin/zsh
|
||||||
|
# mail: rob@example.com
|
||||||
|
# objectClass: top
|
||||||
|
# inetOrgPerson
|
||||||
|
# hostObject
|
||||||
|
# posixAccount
|
||||||
|
# sn: McBroom
|
||||||
|
# uid: rob
|
||||||
|
# uidNumber: 99999
|
||||||
|
# ]
|
||||||
|
|
||||||
|
########################################
|
||||||
@@ -63,6 +63,7 @@ INSTALLED_APPS = [
|
|||||||
'rest_framework',
|
'rest_framework',
|
||||||
'django_filters',
|
'django_filters',
|
||||||
'django_static_jquery_ui',
|
'django_static_jquery_ui',
|
||||||
|
'accounts.apps.AccountsConfig',
|
||||||
'posts.apps.PostsConfig',
|
'posts.apps.PostsConfig',
|
||||||
'members.apps.MembersConfig',
|
'members.apps.MembersConfig',
|
||||||
'documents.apps.DocumentsConfig',
|
'documents.apps.DocumentsConfig',
|
||||||
|
|||||||
Reference in New Issue
Block a user