Update to the Problem: we have a solution

So a few months ago there was a problem Where I continue to admire the Problem without a complete Solution. This has been solved for a few months, but sh!t happens. Am now finally getting around to providing the a solution, one that works for me, but may not work for you. This is pieced together haphazardly, mainly so I have note of it and well so if you’re looking for help on doing something similar you have a much better starting point than I did.

After a hot minute with Python-LDAP I determined it was a beast I was not interested in taming at the moment because well I had another option, mind you at the time we thought this ‘other’ option was going to be easier. I don’t know if it was or not, but it took some serious neuron firing to do.

At one point I dove deep into VBA scripting, where I figuratively lost loads of hair and age 20 years. The script scraped hundreds of emails for a text string (unique ID), to parse out into an excel file (staying within the suite of Microsoft Office deemed significantly easier than going out) and then ran line by line on LDAP to print the output of the request attributes and then convert to csv and email to colleague to do a mail merge.

**confession** I actually signed up for a Stack Overflow account because of this!

One Solution but not THE solution:

VBScript and a Bash script that ran LDAP Queries, Python conversions and used Mutt to send an email attachment.
I’ve changed values to neutral values, you will need to update them to match what you need.
Here is my repo that provides the files you’ll need if you decide to take the VBScript route. https://github.com/whitni/VBScriptandLDAP

Once you set this up in VBA, you can set it as a macro, but I had it set as a rule at first and then switched to doing something different right after I had this solution in place…so didn’t bother.

The Solution I settled on:

I returned to a single bash script that queried LDAP matching on certain attributes, primary change was the decision to send emails out based on start dates and not when we received an email notification from HR. This will soon be turned into a cron job and I can dust my hands of it BUT walking away with significantly more knowledge of LDAP, AD, VBA and all that…

#!/bin/bash
#A simple script

## date format ##
today=$(date +”%F”)
startdate=$(date +”%Y%m”)

##backup path ##
BAK=”/path/that/you/saved/file/newhires_$today”

# LDAP Search query
ldapsearch -W -h your.AD.server.com -x -D ldapusername@email.com -b “dc=$1,dc=$2,dc=$3” -s sub “attributes you need to match or not match on” attributes you want > $BAK

#convert LDIF to csv
python LDIFtoCSV/LDIFtoCSV.py $BAK > /path/that/you/saved/file/newhires_$today.csv

#send email with file attached
mutt -a /path/that/you/saved/file/newhires_$today.csv -s “New Hire Emails” -c persontoCC@email.com — persontoemail@email.com

Resources used:
VBScript Library: https://msdn.microsoft.com/en-us/library/aa227499(v=vs.60).aspx
RegEx parsing: http://www.slipstick.com/developer/regex-parse-message-text/
LDAP Man page: [Linux_terminal] > man ldap
LDIFtoCSV conversion tool: https://github.com/tachang/ldiftocsv
Stack Overflow — my question: http://stackoverflow.com/questions/36752876/why-does-copying-a-string-from-outlook-to-excel-open-a-new-instance-of-excel-for/36754211#36754211

Advertisements

My first shot at installing Ubuntu (Windows PC_netbook)

So I realized that I am lacking significantly on some of the key tools with server admin >> system admin. Linux/UNIX experience.

I am working with an old (2008) HP mini 5101, Intel Atom N280 .66GHz, 1GB memory, 160GB HD, currently running Windows 7, originally came with XP.

I’m documenting my experience to hopefully provide help/insight to others who decide to venture down the same path with the same level of experience that I have.

I started with this article <http://librarian-dev-ops-intro.readthedocs.org/en/latest/intro.html> shared with me from my Twitter “cry for help”. (Thanks @Kayiwa!)

“It is yes written to install Ubuntu as a virtual machine but it should essentially amount to DL ISO and burn install.” (Exact words from the response to my cry.)

Since I am installing this on a Netbook I first need to DL Ubuntu and then put it on a USB so I can boot it on my netbook (read no CD drive to burn disc from) You can read about how to do this here: Ubuntu documentation installation/From USB stick This article is pretty straight forward so you should not have any issues doing this. **I didn’t follow the document, I kinda just did it my way**

Once you have the ISO on your flashdrive it’s a plug and play & reboot and wait.

This is by far one of the easiest installations I’ve done and I didn’t use more than the URLs in the first article to get myself started. Probably because I really only need the URL for the ISO DL. But I do see myself most likely referring back to it for the Ubuntu Intro.

UPDATE: not as easy as I thought it would be. I thought that it was going to be a very easy install but with my lack of knowledge (surprisingly so) it wasn’t as easy as what I thought it was going to be. I started with writing this: “seriously it was give or take 5 steps to get my netbook running Ubuntu (this is assuming you have a little more than a basic knowledge of DL and installing software)

1. Go here and DL ubuntu (http://www.ubuntu.com/download/desktop)

2. Open the DL and Copy to USB stick (make sure USB is 2GB)

3. run from USB device on netbook & reboot (it tells to you, you just click yes)

4. Let it run it’s magic and then refer to this link to get you started (http://librarian-dev-ops-intro.readthedocs.org/en/latest/ubuntuintro.html)

On to bigger and better things. ”

Then a couple of hours later I ran into this annoying error that wouldn’t let me actually boot Ubuntu. (see a forum thread here about the error: Forum thread about serious errors….)

It seemed pretty straight forward on install but if you have NEVER installed an OS before either from bare or along side another OS then it’s not entirely straight forward but this will tell you what I did and it worked for me. Keep in mind if you aren’t currently running Ubuntu you need to ignore all the documentation for creating a bootable USB that mentions “Open the dash and search for Startup Disk Creator.” because well you AREN’T using ubuntu yet so you can’t access this.

Do this instead.

1. Install UnetBootin (http://unetbootin.sourceforge.net) you’ll go through the steps to select your drive and install onto the USB.

2. Insert USB into netbook and install Ubuntu (usually accessed by opening USB and double clicking on the .exe file), you’ll need to reboot the comp (it asks you). This is where I ran into all sorts of errors until for some reason or other decided to boot the comp into boot menu where I then was able to run from the USB disc and WALLAH! I got the menu for installing Ubuntu. (documentation on this is slightly confusing & vague or I’m a bone head)

For my first install I decided to install along side windows 7 until I am really sure I won’t ever need it or any of the programs again and then I will perform a whole new install.