Re: Bulk update loginShell for 100 users

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



#!/bin/bash

for u in `ldapsearch -x -LLL ObjectClass=person | grep uid: | awk '{ print $2 }'`
  do
      rm -f /tmp/$u.ldif
      touch /tmp/$u.ldif
      echo "writing $u"
      echo "dn: uid=$u,ou=People,dc=example,dc=com" >> /tmp/$u.ldif
      echo "changetype: modify" >> /tmp/$u.ldif
      echo "replace: loginshell" >> /tmp/$u.ldif
      echo "loginshell: /bin/nologin" >> /tmp/$u.ldif
      echo "" >> /tmp/$u.ldif
      ldapmodify -x -D "cn=Directory Manager" -w 'REDACTEDPW' < /tmp/$u.ldif
      rm -f /tmp/$u.ldif
  done


\o/
________________________________________
From: Kapetanakis Giannis <bilias@xxxxxxxxxxxxxxxxxx>
Sent: Monday, May 1, 2017 11:41 AM
To: 389-users@xxxxxxxxxxxxxxxxxxxxxxx
Subject: [389-users] Re: Bulk update loginShell for 100 users

On 01/05/17 19:52, Tus wrote:
> Hello 389-users:
>
> I'm looking for ideas to update ~100 uid's loginShell to /bin/nologin. For
> the most part I use ADS to maintain the LDAP server but familiar with
> modifying ONE entry using ldif file fed into ldapmodify.. What are some
> good ways to bulk update?
>
> Cheers.
>

ldif file fed to ldapmodify

dn: uid=user1,ou=People,dc=example,dc=com
changetype: modify
replace: loginshell
loginshell: /bin/nologin
-

dn: uid=user2,ou=People,dc=example,dc=com
changetype: modify
replace: loginshell
loginshell: /bin/nologin
-

I usually do first an ldapsearch to get all the DNs I need and then in
vi I add the rest of the details.

G
_______________________________________________
389-users mailing list -- 389-users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to 389-users-leave@xxxxxxxxxxxxxxxxxxxxxxx

CONFIDENTIALITY NOTICE: This message is the property of International Game Technology PLC and/or its subsidiaries and may contain proprietary, confidential or trade secret information. This message is intended solely for the use of the addressee. If you are not the intended recipient and have received this message in error, please delete this message from your system. Any unauthorized reading, distribution, copying, or other use of this message or its attachments is strictly prohibited.
_______________________________________________
389-users mailing list -- 389-users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to 389-users-leave@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora User Discussion]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora News]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora QA]     [Fedora Triage]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Yosemite Photos]     [Linux Apps]     [Maemo Users]     [Gnome Users]     [KDE Users]     [Fedora Tools]     [Fedora Art]     [Fedora Docs]     [Maemo Users]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Fedora ARM]

  Powered by Linux