Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nehovahralph

macrumors newbie
Original poster
Apr 20, 2007
5
0
Hi all,
Newly joined the forum......Can anyone help me how to find the name of the workgroup of my machine using cocoa programming.(ie using code i want to find the name of my workgroup.
 
I'm 99% certain that you can't access this directly from Cocoa. If SMB sharing is not turned on I'm not sure that you will be in ANY workgroup.

You can either shell out to one of the SAMBA tools (sorry not sure which one) or parse the smb config file.
 
Thanks but

Hi,
I am very thankful to u for sharing ur knowledge with me but as u know that we cannot see in which workgroup our machine belongs from our own machine .So is there any API either in cocoa or in carbon to display my machine's workgroup name by sitting on my own machine.If there is any API kindly inform me .
Thanking u.
 
You can see which workgroup you are a member of.

Run Applications->Utilities->Directory Access then look under SMB/CIFS and it will tell you what Workgroup you are a member of
 
There is no declared API that I am aware of. SAMBA is running on the machine. Either connect to it at 127.0.0.1 and ask it, parse the config file, or run the underlying utility that Directory Access is calling (it is almost certainly not using an API but calling a subtask).
 
Hi all,
As i had mentioned previously,I want a code by which I can get my machine's workgroup name .Using Directory acces utility ,I know that we can get the machine's workgroup name.But my requirement is that I need a code to be written in my project to get the machine's workgroup name.So ,if any of u have any idea on how to do this kindly send ur opinions.
 
I've already suggested twice how to do it. I state again there is no Cocoa API for this[/url]. Probably the easiest way is to grab the config line from the smb configuration file and parse it in Cocoa.

The file is /etc/smb.conf. This Unix command will get the line we need:

Code:
grep "workgroup =" /etc/smb.conf

Then using a combination of NSTask and NSString's componentsSeparatedByString: you should be able to get the workgroup in a few lines of code.
 
Hi all,
Thanks for sharing with me regarding smb.conf file where the workgroup name is given .But others in my network can see my system in Finder->network->My network eventhough I had set my workgroup name to Finder->network->Fortune.Why is this happening ?Why does my system be seen in the workgroup Fortune.Kindly check it out?
 
Altering the contents of the config file will have no effect until the daemons that provide the smb services are restarted as they only read the files when they start. Either reboot the machine, turn Windows file sharing off then on in System preferences or read up on using launchd to restart the daemons.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.