Programmatically Retrieve OSX Network/Proxies configuration values
Asked Answered
M

2

4

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.

Mcclinton answered 1/12, 2010 at 18:12 Comment(0)
M
6

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;
Mcclinton answered 6/12, 2010 at 15:53 Comment(0)
E
4

Look at the scutil command. In particular, scutil --proxy will show the proxies

Egotism answered 2/12, 2010 at 14:58 Comment(1)
Thanks. I was looking for a programmatic way from a Cocoa application.Mcclinton

© 2022 - 2024 — McMap. All rights reserved.