Loading up Active Directory with lots of groups

Loading up Active Directory with lots of groups can be a tedious task, but it can be made easier by following some steps. I recently had to do this to test a product to make sure that it can handle a large amount of data. I started with a list of job titles. Found that those titles were not enough groups and so ended up using a list of animals as the groups input to provide the script to automate the process of creating groups in Active Directory.

First, let’s assume that you already have Active Directory set up and that you have the necessary permissions to create groups. We will use the ldif template provided in the question to create groups in Active Directory.

Here is the step-by-step process to load up Active Directory with lots of groups:

  1. Prepare the list of groups: In our example, the list of animals is provided in the question. You can create your own list of groups based on your requirements.
  2. Create an ldif file: Use the ldif template provided in the question to create an ldif file that contains the group details. Make sure to replace {groupname} in the template with the actual name of the group.
  3. Run a for loop: To automate the process of creating groups, we can use a while loop that reads the list of groups and creates the groups in Active Directory using the ldif file. Here’s an example script:
#!/bin/bash

# Read the list of groups from a file
while read -r group; do
  # Replace {groupname} in the ldif file with the actual group name
  sed "s/{groupname}/$group/" group.ldif >> temp.ldif
  # Create the group in Active Directory using ldapadd command
  ldapadd -x -D "CN=Administrator,CN=Users,DC=mydomain,DC=com" -w password -f temp.ldif
done < groups.txt

In the above script, replace the following:

  • group.ldif with the name of the ldif file that you created in step 2.
  • groups.txt with the name of the file that contains the list of groups.
  • CN=Administrator,CN=Users,DC=mydomain,DC=com with the actual Distinguished Name (DN) of the user account that you want to use to create the groups.
  • password with the password for the user account.
  1. Run the script: Save the script to a file (e.g., create-groups.sh) and make it executable using the command chmod +x create-groups.sh. Then run the script using the command ./create-groups.sh.

That’s it! The script will create all the groups in the list and add them to Active Directory. You can modify the ldif template and the script as per your requirements to create groups with different attributes and properties.

How to backup your iPhoto pictures and videos to a NAS w/ rsync

This is how I backup my iPhoto stuff. I know that Apple has tools to do this, but I don’t use TimeMachine and keep most of my backups on my NAS.

I also keep my iPhoto Library on an external drive (to save space on my local SSD drive).

This is the simple script that I run in the Terminal:

#!/bin/bash
    if [ -d /Volumes/Monster/Private/iphoto_pictures ]; then
    if [ -f lock ]; then
exit 1
    fi
      touch lock
rsync -av /Volumes/Fujin/iPhoto\ Library.photolibrary/ /Volumes/Monster/Private/iphoto_pictures/iPhoto\ Library
   rm -rf lock
     fi;

What I’m doing here is first off, checking to see if the NAS is mounted. In my case, my mount name is “Monster” and the directory were I put my pictures is /Private/iphoto_pictures, so I check to see if the directory exists. If it does, I proceed to check if a lock exists. The reason I create a lock is so that I don’t have more than 1 backup job running at once. I keep this script running in my crontab, so that if the NAS is mounted and there is no lock, it will call rsync to copy all of the files in my iPhoto library into the one on the NAS.

I’ve had no issues with restoring so far – to restore, just need to rsync the other way.

Hope this helps.