Hugo's Blog

#scripting

Accessing Active Directory in PHP using ADLDAP

Lately, our company has started developing user web portals for our clients. The main goal is to provide a central reference point for common links (webmail, helpdesk, remote assistance links ... ), howto documents, and other files and resources. A secondary goal was to also allow user administrators to perform basic user management through a web interface. This would include things like disabling/creating/unlocking user accounts, resetting passwords, and modifying group memberships for access reasons. Myself and the other admin tasked with setting up this portal are most familiar with PHP, and so we went of looking for the best means of interfacing with Active Directory through PHP…
·
Accessing Active Directory in PHP using ADLDAP

Find Disabled and Inactive User and Computer Accounts using Powershell - Part I

We'll start off with Inactive accounts first, and then work on the disabled accounts after that. Active Directory in Server 2003 has a nice user/computer attribute called lastLogonTimeStamp that can help us keep track of inactive accounts. If you have ever tried to use that attribute, however, you might have come up with something like this…
·
Find Disabled and Inactive User and Computer Accounts using Powershell - Part I

Find Disabled and Inactive User and Computer Accounts using Powershell - Part II

Part I demonstrated how to find aged or inactive accounts, and in Part II we will look at another lingering account type: disabled accounts. Like inactive accounts, Directory Searchers also come in handy for disabled accounts. We can also, however, read an Active Directory account's status directly from a hidden attribute on the ADSI object. Let's start with the Directory Searcher method. This entry also draws from Bahram’s Blog. The code: $adobjroot = [adsi]'' $objdisabsearcher = New-Object System.DirectoryServices.DirectorySearcher($adobjroot) $objdisabsearcher.filter = "(&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=2))" $resultdisabaccn = $objdisabsearcher.findall() | sort path…
·
Find Disabled and Inactive User and Computer Accounts using Powershell - Part II

Bulk Rename Files with Sequential Index

I am pretty sure I'm not the only one who wants something more descriptive than DSC1900298.JPG to name my digital photos. And yes, I know that Windows Explorer allows you to rename pictures en masse, but I don't like the convention they have chosen in that the first file is named [common name].JPG, then the subsequent files are named [common name] (2).JPG and so on and so forth. I had a few requirements for how I wanted to go about this: Get rid of the parentheses. If I will be posting those pics online anywhere, I wanted to keep the names as free of special characters as I can. Number the first file. The Windows Explorer route does not number the first file when doing bulk renames. This is easy enough to do manually, but I just don't want to bother. Keep a constant number of digits in the index number. I want the renaming process to take into account how many pictures there are and adjust the number of index digits accordingly. If there are fewer than 10 files/images, then only 1 digit is required (e.g. 1, 2, 3, 4...9). If there are between 10 and 99 files (inclusive), then two digits are required (01, 02, 03...10, 11, 12...99). I think you get the idea. Windows definitely doesn't do that…
·
Bulk Rename Files with Sequential Index