Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically Retrieve OSX Network/Proxies configuration values

Considering my application has the user ID and Password for the admin user currently logged in, is it possible to retrieve the configuration values from the OSX Network settings? Particularly interested in the "Advanced/Proxies" tab content.

like image 268
JasonGenX Avatar asked Feb 26 '23 17:02

JasonGenX


1 Answers

Did it with the settings API. Here's an example to fetch the PAC URL string from the OSX Network Settings.

static char url[257] = {0};

NSDictionary * proxies = (NSDictionary *)SCDynamicStoreCopyProxies(NULL);
NSString * pacURL = [proxies objectForKey:(NSString *)kSCPropNetProxiesProxyAutoConfigURLString];

if (NULL != pacURL)
{
    strncpy((char*) (&(url)[0]), 
            [pacURL cStringUsingEncoding:NSASCIIStringEncoding],
            sizeof(url));
}
return url;
like image 137
JasonGenX Avatar answered May 09 '23 10:05

JasonGenX