summaryrefslogtreecommitdiff
path: root/service/inetorg-add.lisp
blob: a55f72d30b860b68974e9d44e72497001eba3e72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
(declaim (optimize (speed 0) (safety 3) (debug 3)))

(in-package #:ldapadmin)

;; ========================================================================== ;;
;; inetorg-add

(defclass inetorg-add (auth-service generic-form)
  ((instructions :initarg :instructions
                 :initform nil
                 :accessor instructions))
  (:documentation ""))

(define-generic-form-constructor (inetorg-add "inetorg-add-form" "/inetorg/add/submit")
    '((:name "add-givenname" :label "givenName" :field-type "text")
      (:name "add-sn" :label "sn" :field-type "text")
      (:name "add-mail" :label "mail" :field-type "text")
      (:name "add-postaladdress" :label "postalAddress" :field-type "text")
      (:name "add-postalcode" :label "postalCode" :field-type "text")
      (:name "add-st" :label "st" :field-type "text")
      (:name "add-l" :label "l" :field-type "text")
      (:name "add-telephonenumber" :label "telephoneNumber" :field-type "text")
      (:name "add-mobile" :label "mobile" :field-type "text")
      (:name "add-submit" :label "Create InetOrg Entry" :field-type "button")))

(defun inetorg-add-json ()
  (with-auth (instance inetorg-add)
    (setf (instructions instance) "Use the form to add a new InetOrg entry.")))

;; ========================================================================== ;;
;; inetorg-add-submit

(defclass inetorg-add-submit (auth-service)
  ((location-p :initarg :location-p
               :initform nil
               :accessor location-p))
  (:documentation ""))

(defun inetorg-add-submit-json (givenname sn mail postaladdress postalcode st l telephonenumber mobile)
  (with-auth (instance inetorg-add-submit)
    (with-ldap (ldap)
      (let ((ldap-user (make-instance 'ldap-user
                                      :givenname givenname
                                      :sn sn
                                      :mail mail
                                      :postaladdress postaladdress
                                      :postalcode postalcode
                                      :st st
                                      :l l
                                      :telephonenumber telephonenumber
                                      :mobile mobile)))
        (add-ldap-user ldap-user ldap)
        (setf (message instance) "InetOrg entry created successfully.")))))