欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

common_user_to_admin 普通用户到 (变成 转变为转为)管理员 管理员到普通用户 自己亲自做的 jamf self service 有大用


普通用户转为管理员


#!/bin/bash    
#    
#管理员密码    
Passwd=$(/usr/bin/osascript -e 'display dialog "请输入管理员密码" with hidden answer default answer "" with icon note buttons {"Continue"} default button "Continue"    
    set result1 to result    
    set the text_data to text returned of the result    
    set the button_data to button returned of the result1    
    if button_data = "Cancel" then    
      return ""    
    end if    
    return text_data')  
if [ -z "$Passwd" ];then    
  exit 0;
fi  
if [ $Passwd = 'aaaaaaaa'  ]; then    
    userName=$(/usr/bin/osascript -e 'display dialog "请输入用户名,一般是JS-工号,可在 /Users/ 目录下面查看" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue"    
    set the date_data to text returned of the result    
    return date_data')    
   
    sudo dscl . -append /Groups/admin GroupMembership $userName    
    $(/usr/bin/osascript -e  'display dialog "操作成功,请重启电脑!" buttons {"OK"}   default button "OK"')
    echo "OK";

   
fi    





管理员转为普通用户


#!/bin/bash    
#    
#管理员密码    
Passwd=$(/usr/bin/osascript -e 'display dialog "请输入管理员密码" with hidden answer default answer "" with icon note buttons {"Continue"} default button "Continue"    
    set result1 to result    
    set the text_data to text returned of the result    
    set the button_data to button returned of the result1    
    if button_data = "Cancel" then    
      return ""    
    end if    
    return text_data')  
if [ -z "$Passwd" ];then    
  exit 0;
fi  
if [ $Passwd = 'aaaaaaaa'  ]; then    
    userName=$(/usr/bin/osascript -e 'display dialog "请输入用户名,一般是JS-工号,可在 /Users/ 目录下面查看" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue"    
    set the date_data to text returned of the result    
    return date_data')    
   
    sudo dscl . -delete /Groups/admin GroupMembership $userName    
    $(/usr/bin/osascript -e  'display dialog "操作成功,请重启电脑!" buttons {"OK"}   default button "OK"')
    echo "OK";

   
fi    


普通分类: