-- Applescript to ask for username/password. repeats if incorrect.
repeat
-- Ask for user name
set userName to text returned of (display dialog "enter your user name" with title "User Name" default answer "" buttons {"Cancel", "Okay"} default button 2)
-- Asks for password
set myPassword to text returned of (display dialog "enter your password" with title "User Name" default answer "" buttons {"Cancel", "Okay"} default button 2 with hidden answer)
-- Sets users network share path
set userShare to "smb://" & userName & ":" & myPassword & "@ourserver/usershare/" & userName & ""
try
-- Attempts to mount the above location
mount volume userShare
-- This where the script pauses on the OSX connect to server prompt
--checks to see if users share is mounted in /volumes/
if " & userName & " is in (do shell script "/bin/ls /volumes") then
--exits loop
exit repeat
end if
end try
end repeat我维护着一个iMac实验室,教师现在需要学生使用本地帐户,但需要访问他们的网络共享。学生加入了Active Directory,但在这种情况下,孩子是以通用的本地“iMacs”帐户登录的。
我有一个applescript,它要求输入用户的用户名和密码,但只有在提供的用户名和密码正确的情况下才能正常工作。否则,当用户名或密码输入错误时,将启动"connect to server“提示。
我正在尝试查看是否有方法来处理此提示,或者如果输入的用户名不正确,则完全跳过该提示。这个提示符看起来基本上是在“暂停”脚本。如果我按下cancel,脚本将再次启动,用户可以重新输入用户名和密码。
这是由年轻的小学生使用的,因此限制错误对教师很有帮助。
有什么想法吗?我想我正在寻找的是一种将凭据传递给我们的服务器的方法,查看它们是否正确,然后尝试挂载网络共享。
发布于 2016-09-20 00:34:55
通过使用ldapsearch绑定到AD并验证用户名和密码,我最终找到了我想要的东西。
https://stackoverflow.com/questions/35467807
复制相似问题