Skip to content
This repository has been archived by the owner on Nov 14, 2017. It is now read-only.

Commit

Permalink
122
Browse files Browse the repository at this point in the history
  • Loading branch information
macmule committed Nov 23, 2015
1 parent cef09a3 commit 01e64ff
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 56 deletions.
19 changes: 18 additions & 1 deletion ADPassMon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
391FC4F21361276900D2E33C /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = 391FC4F11361276900D2E33C /* README.md */; };
39925B9F133CE6E8001C9566 /* LaunchAtLoginController.m in Sources */ = {isa = PBXBuildFile; fileRef = 39925B9E133CE6E8001C9566 /* LaunchAtLoginController.m */; };
39952F35133BAD5800A8DD42 /* StatusMenuController.m in Sources */ = {isa = PBXBuildFile; fileRef = 39952F34133BAD5800A8DD42 /* StatusMenuController.m */; };
39D5363D1BB0744400D64989 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 39D5363B1BB0744400D64989 /* MainMenu.xib */; settings = {ASSET_TAGS = (); }; };
39D5363D1BB0744400D64989 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 39D5363B1BB0744400D64989 /* MainMenu.xib */; };
39DC46FB1B6A6DF000AABB81 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 39DC46FA1B6A6DF000AABB81 /* Images.xcassets */; };
7C36C8481B9837C100D56827 /* AppIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 7C36C8471B9837C100D56827 /* AppIcon.icns */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -154,6 +154,7 @@
39094F1C1338DBE4007821C2 /* Frameworks */,
39094F1D1338DBE4007821C2 /* Resources */,
39925BA9133D064F001C9566 /* CopyFiles */,
7CC7A3981C03D1FE00853A3A /* ShellScript */,
);
buildRules = (
);
Expand Down Expand Up @@ -205,6 +206,22 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
7CC7A3981C03D1FE00853A3A /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#\n# Sets the version string to a monotonically increased string, based on\n# the number of git commits.\n\nset -o errexit\nset -o nounset\n\nVERSION=$(git --git-dir=\"$PROJECT_DIR/.git\" --work-tree=\"$PROJECT_DIR\" log | grep '^commit' | wc -l)\n/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion $VERSION\" \"$TARGET_BUILD_DIR/$INFOPLIST_PATH\"";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
39094F1B1338DBE4007821C2 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "ADPassMon/ADPassMonAppDelegate.applescript"
timestampString = "462975679.670168"
timestampString = "470012547.311164"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "1519"
endingLineNumber = "1519"
landmarkName = "on applicationWillFinishLaunching_(aNotification)"
startingLineNumber = "1567"
endingLineNumber = "1567"
landmarkName = "on startMeUp_(sender)"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
Expand Down
2 changes: 1 addition & 1 deletion ADPassMon/ADPassMon-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>2.20.10</string>
<string>2.20.11</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
145 changes: 97 additions & 48 deletions ADPassMon/ADPassMonAppDelegate.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ Enable it now?" with icon 2 buttons {"No","Yes"} default button 2)
end try
if "ANSWER SECTION" is in digResult
set my onDomain to true
log "Domain reachable."
my statusMenu's itemWithTitle_("Refresh Kerberos Ticket")'s setEnabled_(1)
-- Set variable to boolean
set allowPasswordChange to allowPasswordChange as boolean
Expand All @@ -461,9 +462,83 @@ Enable it now?" with icon 2 buttons {"No","Yes"} default button 2)
my statusMenu's itemWithTitle_("Change Password…")'s setEnabled_(0)
end if
end domainTest_


-- Test to see if we're on the domain
on intervalDomainTest_(sender)
domainTest_(me)

-- Grab domain name from bind information
set domain to (do shell script "/usr/sbin/dsconfigad -show | /usr/bin/awk '/Active Directory Domain/{print $NF}'") as text

-- Test domain connectivity
try
set digResult to (do shell script "/usr/bin/dig +time=2 +tries=1 -t srv _ldap._tcp." & domain) as text
on error theError
log "Domain test timed out."
set my onDomain to false
my statusMenu's itemWithTitle_("Refresh Kerberos Ticket")'s setEnabled_(0)
my statusMenu's itemWithTitle_("Change Password…")'s setEnabled_(0)
return
end try

-- For UI update
delay 0.1

-- If the get an answer from the above dig command
if "ANSWER SECTION" is in digResult
set my onDomain to true
log "Domain reachable."
my statusMenu's itemWithTitle_("Refresh Kerberos Ticket")'s setEnabled_(1)
-- Set variable to boolean
set allowPasswordChange to allowPasswordChange as boolean
-- If password change is allowed, show
if allowPasswordChange is true
my statusMenu's itemWithTitle_("Change Password…")'s setEnabled_(1)
-- If password change is not allowed, but a password policy is set, show (as this will show policy).
else if pwPolicyURLButtonTitle is not equal to "" and pwPolicyURLButtonURL is not equal to ""
my statusMenu's itemWithTitle_("Change Password…")'s setEnabled_(1)
end if
else
set my onDomain to false
log "Domain not reachable."
my statusMenu's itemWithTitle_("Refresh Kerberos Ticket")'s setEnabled_(0)
my statusMenu's itemWithTitle_("Change Password…")'s setEnabled_(0)
end if

-- If we're on the domain
if my onDomain is true
canPassExpire_(me)
-- If password can expire
if passExpires
-- if we're using Auto and we don't have the password expiration age, check for kerberos ticket
if my expireDateUnix = 0 and my selectedMethod = 0
doKerbCheck_(me)
if first_run -- only display prefs window if running for first time
if prefsLocked as integer is equal to 0 -- only display the window if prefs are not locked
log "First launch, waiting for settings..."
theWindow's makeKeyAndOrderFront_(null)
set my theMessage to "Welcome!\nPlease choose your configuration options."
set first_run to false
tell defaults to setObject_forKey_(first_run, "first_run")
end if
end if
else if my selectedMethod is 1
set my manualExpireDays to expireAge
set my isHidden to true
set my isManualEnabled to true
doProcess_(me)
else if my selectedMethod is 0
set my isHidden to false
set my isManualEnabled to false
set my manualExpireDays to ""
doProcess_(me)
end if

watchForWake_(me)

else
log "Stopping."
end if
end if
end intervalDomainTest_

-- Check if password is set to never expire
Expand Down Expand Up @@ -1149,10 +1224,17 @@ Enable it now?" with icon 2 buttons {"No","Yes"} default button 2)
tell defaults to set my pwPolicyURLButtonBrowser to objectForKey_("pwPolicyURLButtonBrowser") as string
-- If either pwPolicyURLButtonTitle or pwPolicyURLButtonURL is not set, then display standard pwPolicy prompt
if pwPolicyURLButtonTitle is "" or pwPolicyURLButtonURL is ""
-- Display password policy dialog
tell application "System Events" to display dialog pwPolicy with icon 2 buttons {"OK"}
-- If both pwPolicyURLButtonTitle or pwPolicyURLButtonURL are set, then display second button
else if pwPolicyURLButtonTitle is not equal to "" and pwPolicyURLButtonURL is not equal to ""
-- If pwPolicyButton is not set
if pwPolicyButton is ""
-- Display password policy dialog
tell application "System Events" to display dialog pwPolicy with icon 2 buttons {"OK"}
-- if pwPolicyButton is set
else
-- Display password policy dialog with custom button
tell application "System Events" to display dialog pwPolicy with icon 2 buttons {pwPolicyButton}
end if
-- If both pwPolicyURLButtonTitle or pwPolicyURLButtonURL are set, then display second button
else if pwPolicyURLButtonTitle is not equal to "" and pwPolicyURLButtonURL is not equal to ""
-- Display password policy dialog
tell application "System Events" to display dialog pwPolicy with icon 2 buttons {"OK", pwPolicyURLButtonTitle}
-- If pwPolicyURLButtonTitle...
Expand All @@ -1172,7 +1254,7 @@ Enable it now?" with icon 2 buttons {"No","Yes"} default button 2)
-- If users chose the URL, then we don't want to proceed
set pwPolicyUpdateExternal to true
end if
else
else
-- Set variable to boolean
set allowPasswordChange to allowPasswordChange as boolean
-- If password change is not allowed, then proceed
Expand Down Expand Up @@ -1482,47 +1564,14 @@ Please choose your configuration options."
notifySetup_(me)
doSelectedBehaviourCheck_(me) -- Check for Selected Behaviour
createMenu_(me) -- build and display the status menu item
domainTest_(me) -- test domain connectivity
if my onDomain is true
canPassExpire_(me)
if passExpires
-- if we're using Auto and we don't have the password expiration age, check for kerberos ticket
if my expireDateUnix = 0 and my selectedMethod = 0
doKerbCheck_(me)
if first_run -- only display prefs window if running for first time
if prefsLocked as integer is equal to 0 -- only display the window if prefs are not locked
log "First launch, waiting for settings..."
theWindow's makeKeyAndOrderFront_(null)
set my theMessage to "Welcome!\nPlease choose your configuration options."
set first_run to false
tell defaults to setObject_forKey_(first_run, "first_run")
end if
end if
else if my selectedMethod is 1
set my manualExpireDays to expireAge
set my isHidden to true
set my isManualEnabled to true
doProcess_(me)
else if my selectedMethod is 0
set my isHidden to false
set my isManualEnabled to false
set my manualExpireDays to ""
doProcess_(me)
end if

watchForWake_(me)

-- Set a timer to check for domain connectivity every five minutes. (300)
set my domainTimer to NSTimer's scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(300, me, "intervalDomainTest:", missing value, true)

-- Set a timer to trigger doProcess handler on an interval and spawn notifications (if enabled).
set my processTimer to NSTimer's scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_((my passwordCheckInterval * 3600), me, "intervalDoProcess:", missing value, true)
else
log "Stopping."
end if
else
--offlineUpdate_(me)
end if
intervaldomainTest_(me) -- test domain connectivity

-- Set a timer to check for domain connectivity every five minutes. (300)
set my domainTimer to NSTimer's scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_(300, me, "intervalDomainTest:", missing value, true)

-- Set a timer to trigger doProcess handler on an interval and spawn notifications (if enabled).
set my processTimer to NSTimer's scheduledTimerWithTimeInterval_target_selector_userInfo_repeats_((my passwordCheckInterval * 3600), me, "intervalDoProcess:", missing value, true)

end startMeUp_

-- Do processes necessary for app initiation, but check if account is local first
Expand Down
2 changes: 1 addition & 1 deletion ADPassMon/en.lproj/Credits.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

\b Documentation:
\b0 \
{\field{\*\fldinst{HYPERLINK "http://yourmacguy.wordpress.com/ADPassMon/"}}{\fldrslt http://yourmacguy.wordpress.com}}\
{\field{\*\fldinst{HYPERLINK "https://github.com/macmule/ADPassMon/wiki"}}{\fldrslt https://github.com/macmule/ADPassMon/wiki}}\
\

\b With special thanks to:
Expand Down

0 comments on commit 01e64ff

Please sign in to comment.