add accounts for login/logout

This commit is contained in:
2020-08-03 23:45:27 +00:00
parent 757f7e19d6
commit aad82d1a51
7 changed files with 55 additions and 0 deletions

View File

View File

@@ -0,0 +1,3 @@
# from django.contrib import admin
# Register your models here.

5
fet2020/accounts/apps.py Normal file
View File

@@ -0,0 +1,5 @@
from django.apps import AppConfig
class AccountsConfig(AppConfig):
name = 'accounts'

View File

@@ -0,0 +1,3 @@
# from django.db import models
# Create your models here.

View File

@@ -0,0 +1,3 @@
# from django.test import TestCase
# Create your tests here.

40
fet2020/accounts/views.py Normal file
View 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
# ]
########################################

View File

@@ -63,6 +63,7 @@ INSTALLED_APPS = [
'rest_framework',
'django_filters',
'django_static_jquery_ui',
'accounts.apps.AccountsConfig',
'posts.apps.PostsConfig',
'members.apps.MembersConfig',
'documents.apps.DocumentsConfig',