Skip to content

Instantly share code, notes, and snippets.

View macmule's full-sized avatar

macmule macmule

View GitHub Profile
#!/bin/sh
####################################################################################################
#
# License: https://macmule.com/license/
#
####################################################################################################
#############
#
# Add all users to lpadmin
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.macmule.drivesandprinters</string>
<key>Program</key>
<string>/Applications/Macmule Drives And Printers.app/Contents/MacOS/applet</string>
<key>RunAtLoad</key>
<true/>
----------------------------------------------------------------------------------------------------
--
-- License: https://macmule.com/license/
--
----------------------------------------------------------------------------------------------------
-------------------------------
--- User Information
-------------------------------
---- Map Printers
if ADGroups contains "GROUPNAME" then
if installedPrinters does not contain "PRINTERNAME" then
try
do shell script "/usr/sbin/lpadmin -p PRINTERNAME -E -v lpd://PRINTERIP -P PPDLOCATION -L \"PRINTERLOCATION\" -o printer-is-shared=false"
on error
do shell script "/usr/sbin/lpadmin -p PRINTERNAME -E -v lpd://PRINTERIP -P /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/Resources/Generic.ppd -L \"PRINTERLOCATION\" -o printer-is-shared=false"
end try
end if
end if
---- List All Printers
try
set installedPrinters to do shell script "lpstat -a"
on error
set installedPrinters to ""
end try
-- Checks Group Membership for ADGroups contains user & if they are in the correct groups, mount shares. ---------
if ADGroups contains "GROUPNAME" then
mount volume "PROTOCOL://SERVERNAME.FQDN/SHARENAME"
end if
--Home Folder -- Maps the drive specified in the profile field for the AD User continue if user has no profile path set
try
mount volume "smb:" & ADHome
on error
-- If the mount fails
end try
-- Checks to see if account is an AD Account, if its not exit
if accountType is less than 1000 then
tell me to quit
end if
-- Get the Users AD Home Folder
set ADHome to do shell script "dscl " & quoted form of nodeName & " -read /Users/" & loggedInUser & "| grep SMBHome: | cut -c 10- | sed 's/\\\\/\\//g' "
-- Get the Users group membership from AD
set ADGroups to do shell script "dscl " & quoted form of nodeName & " -read /Users/" & loggedInUser & " | awk '/^dsAttrTypeNative:memberOf:/,/^dsAttrTypeNative:msExchHomeServerName:/'"