
############################################################
SEARCH FLAGS setzen:

searchFlags (0=public, 128=confidential)

ldbedit -H /var/lib/samba/private/sam.ldb CN=Sophomorix-First-Password searchflags --option="dsdb:schema update allowed=yes" -b "cn=schema,CN=configuration,DC=...,DC=..."

* ist leider etwas umständlich
* überlebt einen reboot
* wird global verändert (alle Schulen)?
* wie geht das/geht das mit ldap-modify?
  --> einfach nur searchflag attribute ändern
############################################################
Password cloning:

Auslesen fast ALLER Werte aus einem Account
  # ldbsearch --url /var/lib/samba/private/sam.ldb "sAMAccountName=lordjo42"

Manche attribute müssen explizit angefordert werden dass sie erscheinen:
  # ldbsearch --url /var/lib/samba/private/sam.ldb "sAMAccountName=lordjo42" unicodePwd supplementalCredentials


############################################################

msdfs example

[default-school]
        msdfs root = yes
        msdfs proxy = \lmn-hu.schule.caritas.dicv-fr.de\default-school

To set this, issue the following commands:
# delete share to create it new (can be omitted, when editing the existing share, see below)
net conf delshare uni

# create the share new
net conf addshare uni /path  (a path is needed to create the share, this creates more parameters)
net conf setparm uni 'msdfs root' 'yes'
net conf setparm uni 'msdfs proxy' '\lmn-hu.schule.caritas.dicv-fr.de\default-school'

# remove unnecessary stuff
net conf delparm uni 'read only'
net conf delparm uni 'path'
net conf delparm uni 'guest ok'

Test with:
net conf list

smbcacls Bug: statt

/usr/bin/smbcacls -U administrator%'******' //linuxmuster.local/uni iso

/usr/bin/smbcacls -U administrator%'******' //lmn.schule.dicv.de/uni iso


############################################################

E-Mail migration:
cyrus2dovecot


############################################################
quota einrichten:

Reihenfolge:

1) apt install quota

2) Die Partition des share mit quota optionen mounten:
   Hierauf kommts an: jqfmt=vfsv0,usrjquota=aquota.user,grpjquota=aquota.group
   z.B. in /etc/fstab

   /dev/mapper/srv-default--school on \n
      /srv/samba/schools/default-school \n
      type ext4 (rw,relatime,errors=remount-ro,data=ordered,jqfmt=vfsv0,usrjquota=aquota.user,grpjquota=aquota.group)


   umount /srv/samba/schools/default-school
   mount -a

3) 
    quotacheck -cvua    (create verbose userquota all-filesystems)
    quotacheck -cvuga    (create verbose userquota groupquota all-filesystems)


    - davor evtl alte aquota.user löschen mit:
      lsattr /srv/samba/schools/default-school/aquota.user
      --> ----i--A-----e--   immutable bit gesetzt
      chattr /srv/samba/schools/default-school/aquota.user
      rm -rf /srv/samba/schools/default-school/aquota.user
      oder vorher
      quotaoff -a

4) Dafür sorgen dass aquota.user/aquota.group upgedated werden:
   quotaon /srv/samba/schools/default-school

5)  Filesystemquota auf Linuxseite testen:

    repquota -au
    repquota -aus    (s=human readable)

    --> was muss man tun, damit usernamen aufgelöst werden ????

5) /usr/bin/smbcquotas -L //localhost/all -U administrator%'Muster!'

--> smbcquotas examples
    The smbcquotas program manipulates NT Quotas on SMB file shares.
    /usr/bin/smbcquotas -U administrator%Muster! //linuxmuster.local/bsz 

############ Achtung: das scheint nur zu tun, wenn das smb-share einer Partition entspricht
(aquota.user in )

Beispiel:
 net conf list
[all]
	path = /
	guest ok = yes
	read only = no
und 
/dev/mapper/xenialserver--vg-root on / type ext4 (rw,relatime,errors=remount-ro,data=ordered,jqfmt=vfsv0,usrjquota=aquota.user,grpjquota=aquota.group)

#############
############################################################



############################################################
adding a new role
Add the role in sophomorix.ini under
[ROLE]        # for objectclass users
[ROLE_DEVICE] # for objectclass devices

# find, where these roles are used, decide what to do there with the new role
grep "'ROLE'" -r ./
grep "'ROLE_DEVICE'" -r ./


# find lookup tables for all roles, is is correct to alsouse the new role?
grep "'ROLES'" -r ./ 
grep "'ROLES_DEVICE'" -r ./ 

############################################################


############################################################
CSV-Tags entfernen:
grep '\$Id\$' -ir ./
############################################################


############################################################
userAccountControl
---------------------------
enabled/disabled
Passwort change ja, nein
Passwort expires

was braucht man davon

enabled Account: 512, so wird jetzt hardcoded ein user angelegt
disabled Account: 514, 

samba-tool user disable <username>

stellt auf 514 um, wie hier beschrieben:

http://www.selfadsi.de/ads-attributes/user-userAccountControl.htm

samba-tool user enable <username> stellt wieder auf 512 zurück

Umsetzen:
1) userAccountControl (dezimal) lesen
2) Binär umwandeln
3) schauen welche Bits gesetzt sind
4) Daraus gewünschte Einstellungen erkennen (enabled, password expires, ...)
5) prüfen ob was verändert werden muss:
     - enablen/disabeln je nach sophomorixStatus und dazugehörige Zeiten
     - passwort expires, ... falls in school.conf so konfiguriert
6) in sophomorix.update schreiben
7) mit sophomorix-update umsetzen

############################################################


############################################################
ova's importieren

VirtualBox:
Host-only Netzwerk: neu anlegen, IP ist die des Wirts in diesem Host-only Netz

firewall: 
----------------------------------------
  Appliance importieren:
   - Namen ändern vm --> ...
   - Speicher-Ort anpassen 
   - vdi als Plattenabbild
  Interfaces Virtualbox: 
    Adapter1: vboxnet2
    Adapter2: NAT
* booten
* Interfaces in opensense zuweisen
    welches ist WAN, welches LAN

* device LAN einrichten:
  172.16.0.254/12
*  reboot

server: 
----------------------------------------
* Appliance importieren:
   - Namen ändern vm --> ...
   - Speicher-Ort anpassen 
   - vdi als Plattenabbild
* in das richtige voboxnet host-only network bringen: vboxnet2
* einloggen in virtualbox-Fenster
*  IP setzen: 172.16.0.1/12
    - linuxmuster-prepare -s -u -d linuxmuster.local -n 172.16.0.1/12 -f 172.16.0.254
    - reboot
* apt update && apt -y dist-upgrade
* apt install emacs nfs-common sshpass tree make


  emacs .bashrc 
   - color prompt enablen:
     force_color_prompt=yes
   - farbe von 01;32m auf 01;33m  (gelb)
* mount -t nfs 172.16.0.100://home/bz/github /mnt

* snapshot machen

*   linuxmuster-setup
   Hostname: bionic
   IP's: wie oben
   linuxmuster.local (statt linuxmuster.lan, wichtig für tests)


   Danach vorbereiten für die Tests: 
     - die vom setup angelegten admins löschen (wichtig für Tests)
     - cp /etc/linuxmuster/sophomorix/default-school/devices.csv /root/

       server;bionic;nopxe;08:00:27:e0:fc:97;172.16.0.1;;;;server;;0;;;;SETUP;
       server;firewall;nopxe;08:00:27:C7:26:71;172.16.0.254;;;;server;;0;;;;SETUP;


   Zeile in devices.csv für nextcloud
   server;nextcloud;nopxe;08:00:27:38:DF:01;172.16.0.5;;;;;1;0



############################################################

Nextcloud-Anbindung:

1. Binduser erstellen:
   # sophomorix-admin --create-global-binduser nextcloud-bind --password Muster!     (Passwort merken):
   ODER:
   # sophomorix-admin --create-global-binduser nextcloud-bind --random-passwd-save    (Passwort merken lassen):
   Testen mit:
   # sophomorix-admin -i -a nextcloud-bind

2. Nextcloud -> Einstellungen -> Verwaltung -> LDAP/AD Integration

   ##### Reiter 1: Server
    Host: ldap://<IP>    (ldap:// nicht weglassen!)
    Port 389 (ermiteln)
    Bind DN aus # sophomorix-admin -i -a nextcloud-bind
       CN=nextcloud-bind,OU=Management,OU=GLOBAL,DC=linuxmuster,DC=local
    Passwort: Wie angegeben oder wie in /etc/linuxmuster/.secret/nextcloud-bind gespeichert.
    BaseDN: DC=linuxmuster,DC=local

   ##### Reiter 2: Benutzer
    (& (objectClass=user)(| (sophomorixRole=student) (sophomorixRole=teacher) ) )

   ##### Reiter 3: Anmelde-Attribute
       (& (objectclass=user)(sAMAccountName=%uid))

   ##### Reiter 4: Gruppen
   (objectclass=group) liefert auch admin Gruppen und Räume zurück-> mist
   
   --> BESSER: nur sophomorix Gruppen:
    (& (objectClass=group) (| 
        (sophomorixType=adminclass)
        (sophomorixType=extraclass)
        (sophomorixType=teacherclass)
        (sophomorixType=project) 
        (sophomorixType=sophomorix-group) ) 
    )

