Re: Changing IP Address and Config method using the System configur ation framework.
Re: Changing IP Address and Config method using the System configur ation framework.
- Subject: Re: Changing IP Address and Config method using the System configur ation framework.
- From: OL&L Lists <email@hidden>
- Date: Fri, 27 May 2005 10:18:55 -0700
Title: Re: Changing IP Address and Config method using the
System
How does this code work if the user is a non-admin or non-root
user? SCPreferencesCommitChanges requires admin
or root access.
Michael
At 1:59 PM +0530 5/18/05, Sandeep Vaidya wrote:
Hi,
I am able to change the
Network settings using the following code which I wrote for setting
the IP Address.
I am wondering, there will be any change in the
preference file format of the other versions of MAC. Please
let me know if I need to take care of some more
things.
void SetIPAddress(char
*ipAddr)
{
CFStringRef strIPAddr;
CFMutableDictionaryRef level1
= NULL, level2 = NULL, level3 = NULL;
CFMutableArrayRef
array;
SCPreferencesRef
prefs;
prefs = SCPreferencesCreate(NULL,
CFSTR("netutils"),
NULL);
//
Need to replace the text hardcoding with the constants
level1 =
SCPreferencesGetValue(prefs,
CFSTR("NetworkServices"));
// Need to replace with the logic
to get the interface name.
level2 =
CFDictionaryGetValue(level1, CFSTR("0"));
level3 =
CFDictionaryGetValue(level2, CFSTR("IPv4"));
array
= CFArrayCreateMutable(NULL, 5,
&kCFTypeArrayCallBacks);
strIPAddr =
CFStringCreateWithCString(NULL, ipAddr,
CFStringGetSystemEncoding());
CFArrayAppendValue(array,
strIPAddr);
// Need to replace the text
hardcoding with the constants
CFDictionarySetValue(level3,
CFSTR("Addresses"), array);
CFDictionarySetValue(level2,
CFSTR("IPv4"), level3);
// Need to replace with the logic
to get the interface name.
CFDictionarySetValue(level1,
CFSTR("0"), level2);
SCPreferencesSetValue(prefs,
CFSTR("NetworkServices"), level1);
SCPreferencesCommitChanges(prefs);
SCPreferencesApplyChanges(prefs);
CFRelease(strIPAddr);
CFRelease(level1);
CFRelease(level2);
CFRelease(level3);
CFRelease(array);
}
Thanks and
Regards
-Sandeep. Vaidya
This message is
free from Virus - IMSS
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list
(email@hidden)
Help/Unsubscribe/Update your Subscription:
>launch.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden