Admin prompt when forgetting wifi

SMR1
Contributor III

I've messing around with the below script I found, so we can allow some users to forget ssid's. When I forget the wifi, I still get the admin prompt, but if I hit cancel on the prompt, it does forget the ssid. Just trying to figure out how to get the prompt to not show on Sonoma.

 

#!/bin/bash

# Get a list of preferred Wi-Fi networks
wifiList=$(networksetup -listpreferredwirelessnetworks en0 | sed 's/^\*//')

# Present a dialog box for selecting a Wi-Fi network to forget
selectedWifi=$(osascript -e 'choose from list {'"${wifiList}"'} with prompt "Select the Wi-Fi network to forget:"' | tr ',' '\n' | sed -n 2p)

if [ -n "$selectedWifi" ]; then
    # Forget the selected Wi-Fi network without requiring admin privileges
    sudo -u $USER networksetup -removepreferredwirelessnetwork en0 "$selectedWifi"
    echo "Wi-Fi network '$selectedWifi' has been forgotten."
fi

echo "Please select the Wi-Fi network you want to forget."

  

1 ACCEPTED SOLUTION

mschlosser
Contributor II

typically i use the following commands to allow standard users to modify wifi and network settings:

/usr/bin/security authorizationdb write system.preferences.network allow 
/usr/bin/security authorizationdb write system.services.systemconfiguration.network allow
/usr/bin/security authorizationdb write com.apple-wifi allow

View solution in original post

3 REPLIES 3

mschlosser
Contributor II

typically i use the following commands to allow standard users to modify wifi and network settings:

/usr/bin/security authorizationdb write system.preferences.network allow 
/usr/bin/security authorizationdb write system.services.systemconfiguration.network allow
/usr/bin/security authorizationdb write com.apple-wifi allow

StefanT
New Contributor III

This does not work for me on Sonoma, any idea why?

SMR1
Contributor III

For us one of the reasons it wasn't working is because we use CyberArk EPM and for some reason it was blocking it on the version, we were using 22.12. Since we updated to 24.4, we're able to forget old SSID's.