TweetFollow Us on Twitter

Changing Spots

Volume Number: 23 (2007)
Issue Number: 11
Column Tag: MacEnterprise

Changing Spots

New ways of manipulating Directory Services in Leopard

By Philip Rinehart, Yale University

User Account Changes

Occasionally, questions about user accounts and how to maintain them appear on the Macenterprise list. Leopard changes the landscape, as NetInfo no longer exists. What does this mean practically? All user account information is now stored as flat text files. No more messing around with command line utilities like nicl, nidump, etc. All access is now accomplished using the command line directory service utility, dscl. Let's take a look at how it works.

DSCL

Dscl, Directory Service Command Line, utility was originally introduced in Tiger. With the death of NetInfo, it is the new way of manipulating user accounts. Also, astute users may note that NetInfo Manager is now completely gone, so any manipulation of NetInfo attributes must be accomplished by using dscl. Directory Service attributes can be changed, appended or deleted. Let's take a very basic example.

   dscl . -read /Users/myuser

This example operates on the local node by using the period, and returns all of the attributes for myuser. The command returns a list of all of the values that would have been seen in NetInfo Manager. They are printed out as a single line for each value. While interesting, it only begins to tap dscl for its true power. Here's a second example, listing all the users on the local system, as well as their UniqueID values (UID).

   dscl /Local/Default -list /Users UniqueID

This command is a really quick way to list any attribute of any user that is stored in the local Directory Services store. Notice a slight difference in this command? Instead of using a period, the full node is specified, in this case, the local database, /Local/Default. Let's step back just a second. Since NetInfo is gone, where is all the information? Here is the complete path:

   
   /var/db/dslocal/nodes/Default/Users

Explore the contents of the directory, notice how everything is a plist? One of the decisions made when moving away from NetInfo is that all of the information is now stored in xml plist format in the above directory. As an interesting side effect, any properly formatted plist that is added to the user will now appear on the system as a valid user. Returning to our UID example, now that the UID is known for any user, it is a pretty simple operation to change a UID on the fly. Back to dscl:

   
   dscl /Local/Default -create /Users/myuser UniqueID 503

This command takes the current UniqueID value for myuser and overwrites or it with the new value. Instead of the user's previous value for UniqueID, a new one has now been put in place. Note that use of the create option will completely overwrite any current value. If the value does not exist, it creates it in the plist.

PUMP IT UP

All of our example dscl commands will work in Tiger. Dscl in Leopard has been beefed up considerably. It now has the ability to read subkeys through the use of additional command line options. If you ever looked at a NetInfo record that contained mcx information, you know that mcx settings are typically sent to the client as a plist. Now that this information is stored in a flat plist with nested values, dscl needs a way to manipulate the data. New options have been added, readpl, readpli, and createpl, createpli. Unfortunately the syntax is difficult to master, as it requires a very specific format. Here's a somewhat simplified example for managed preferences.

   dscl . -readpl /Users/myuser MCXSettings mcx_application_data:com.apple.finder

Note the syntax of the key, colons separate nested values. In this particular case, the managed preference key for the Finder is read. This example should give you a taste of how the command works, but getting the path exactly right can be a bit tricky. Fortunately, there is a way out of the weeds, with a new mcx options for dscl..

MCX!

One of the major complaints in previous versions of OS X was the inability to easily understand and manipulate managed preferences. Leopard is the first version of OS X that has options to help manage via script, or the command line. It has also been quite difficult to troubleshoot managed client preferences, and to truly understand what is going on when managed preferences are applied. Let's look at our friend dscl again, this time with an eye toward the options that were added to dscl. Here's a very simple example:

   dscl . -readmcx /User/myuser

Note how the information is returned. Each managed preference is returned as a set of values with a consistent format. So for example, if a Finder preference was managed, the value might look like this:

App domain: com.apple.finder
Key: ComputerViewOptions_Arrangement
State: always
Value: None

Cool! The mcxread option is useful, but even more useful is the ability to set, import and export keys with dscl and its associated mcx commands. Imagine being able to set preferences from the command line from a client! A sample process could be:

   dscl . -mcxexport /Users/myuser -o /tmp/export.plist com.apple.finder

This command exports the managed client settings for myuser. The settings can then be altered in the exported file, export.plist with any text editor. Once finished editing, use this command to import the changed values:

   dscl . -mcximport /Users/myuser -d /tmp/export.plist

One note about this command, the -d option deletes any keys that existed previously. It is equivalent to calling mcxdelete for every key found in the import file. There are many options available for command line managed preference manipulation of preferences, which are not documented in the manual page. So how can you find the proper options? Use the flag -mcxhelp.

   dscl . -mcxhelp

This short command returns all of the options available, and is quite thorough in its description of how to use the command line options.

What if you only want to see what managed preferences are being applied? A new command for Leopard, mcxquery has been added. It can be called directly to present all of the options for any known user, group or machine. Here's how:

   mcxquery -user myuser -group mygroup -computer mycomputer

This command returns a list of all managed preferences for all three options. Additionally, it specifies exactly which domain the management is being applied from. If it is a user management preference, it indicates the managed preference. Very useful! Now that Leopard is finally out, a whole new world of discovery awaits us. As always, see you on the lists!


Philip Rinehart is co-chair of the steering committee leading the Mac OS X Enterprise Project (macenterprise.org) and is the Lead Mac Analyst at Yale University. He has been using Macintosh Computers since the days of the Macintosh SE, and Mac OS X since its Developer Preview Release. Before coming to Yale, he worked as a Unix system administrator for a dot-com company. He can be reached at: philip.rinehart@yale.edu. The MacEnterprise project is a community of IT professionals sharing information and solutions to support Macs in an enterprise. We collaborate on the deployment, management, and integration of Mac OS X client and server computers into multi-platform computing environments.

 
AAPL
$97.03
Apple Inc.
-0.16
MSFT
$44.40
Microsoft Corpora
-0.47
GOOG
$593.35
Google Inc.
-2.63

MacTech Search:
Community Search:

Software Updates via MacUpdate

Audio Hijack Pro 2.11.0 - Record and enh...
Audio Hijack Pro drastically changes the way you use audio on your computer, giving you the freedom to listen to audio when you want and how you want. Record and enhance any audio with Audio Hijack... Read more
Intermission 1.1.1 - Pause and rewind li...
Intermission allows you to pause and rewind live audio from any application on your Mac. Intermission will buffer up to 3 hours of audio, allowing users to skip through any assortment of audio... Read more
Airfoil 4.8.7 - Send audio from any app...
Airfoil allows you to send any audio to AirPort Express units, Apple TVs, and even other Macs and PCs, all in sync! It's your audio - everywhere. With Airfoil you can take audio from any... Read more
Microsoft Remote Desktop 8.0.8 - Connect...
With Microsoft Remote Desktop, you can connect to a remote PC and your work resources from almost anywhere. Experience the power of Windows with RemoteFX in a Remote Desktop client designed to help... Read more
xACT 2.30 - Audio compression toolkit. (...
xACT stands for X Aaudio Compression Toolkit, an application that encodes and decodes FLAC, SHN, Monkey’s Audio, TTA, Wavpack, and Apple Lossless files. It also can encode these formats to MP3, AAC... Read more
Firefox 31.0 - Fast, safe Web browser. (...
Firefox for Mac offers a fast, safe Web browsing experience. Browse quickly, securely, and effortlessly. With its industry-leading features, Firefox is the choice of Web development professionals... Read more
Little Snitch 3.3.3 - Alerts you to outg...
Little Snitch gives you control over your private outgoing data. Track background activityAs soon as your computer connects to the Internet, applications often have permission to send any... Read more
Thunderbird 31.0 - Email client from Moz...
As of July 2012, Thunderbird has transitioned to a new governance model, with new features being developed by the broader free software and open source community, and security fixes and improvements... Read more
Together 3.2 - Store and organize all of...
Together helps you organize your Mac, giving you the ability to store, edit and preview your files in a single clean, uncluttered interface. Smart storage. With simple drag-and-drop functionality,... Read more
Cyberduck 4.5 - FTP and SFTP browser. (F...
Cyberduck is a robust FTP/FTP-TLS/SFTP browser for the Mac whose lack of visual clutter and cleverly intuitive features make it easy to use. Support for external editors and system technologies such... Read more

Latest Forum Discussions

See All

LEX Goes Free For One Day In Honor of Ne...
LEX Goes Free For One Day In Honor of New Update Posted by Jennifer Allen on July 24th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Thomas Was Alone Goes Universal, Slashes...
Thomas Was Alone Goes Universal, Slashes Price to $3.99 Posted by Ellis Spice on July 24th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
Meerkatz Challenge Review
Meerkatz Challenge Review By Jennifer Allen on July 24th, 2014 Our Rating: :: FONDLY PUZZLINGUniversal App - Designed for iPhone and iPad Cute and challenging, Meerkatz Challenge is a fun puzzle game, particularly for fans of... | Read more »
Book Your Appointment with F.E.A.R. this...
Book Your Appointment with F.E.A.R. | Read more »
It Came From Canada: Epic Skater
For all the hate that it gets for being a pastime for slackers, skateboarding really does require a lot of skill. All those flips and spins take real athleticism, and there’s all the jargon to memorize. Fortunately for us less extreme individuals,... | Read more »
Cultures Review
Cultures Review By Jennifer Allen on July 24th, 2014 Our Rating: :: SLOW-PACED EMPIRE BUILDINGiPad Only App - Designed for the iPad Cute it might seem, but Cultures is a bit too slow paced when it comes to those pesky timers to... | Read more »
More Paintings Have Been Added to Paint...
More Paintings Have Been Added to Paint it Back! Posted by Jessica Fisher on July 24th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
The Order of Souls Review
The Order of Souls Review By Campbell Bird on July 24th, 2014 Our Rating: :: STORY GRINDUniversal App - Designed for iPhone and iPad The Order of Souls is a free-to-play, turn-based RPG with a genre-mixing art style, interesting... | Read more »
Revolution 60 Review
Revolution 60 Review By Jordan Minor on July 24th, 2014 Our Rating: :: LASS EFFECTUniversal App - Designed for iPhone and iPad Revolution 60 is a bold, cinematic action game with ambition to spare.   | Read more »
Matter (Photography)
Matter 1.0.1 Device: iOS Universal Category: Photography Price: $1.99, Version: 1.0.1 (iTunes) Description: Add stunning 3D effects to your photos with real-time shadows and reflections. Export your creations as photos or video loops... | Read more »

Price Scanner via MacPrices.net

Save on 5th generation refurbished iPod touch...
The Apple Store has Apple Certified Refurbished 5th generation iPod touches available starting at $149. Apple’s one-year warranty is included with each model, and shipping is free. Many, but not all... Read more
What Should Apple’s Next MacBook Priority Be;...
Stabley Times’ Phil Moore says that after expanding its iMac lineup with a new low end model, Apple’s next Mac hardware decision will be how it wants to approach expanding its MacBook lineup as well... Read more
ArtRage For iPhone Painting App Free During C...
ArtRage for iPhone is currently being offered for free (regularly $1.99) during Comic-Con San Diego #SDCC, July 24-27, in celebration of the upcoming ArtRage 4.5 and other 64-bit versions of the... Read more
With The Apple/IBM Alliance, Is The iPad Now...
Almost since the iPad was rolled out in 2010, and especially after Apple made a 128 GB storage configuration available in 2012, there’s been debate over whether the iPad is a serious tool for... Read more
MacBook Airs on sale starting at $799, free s...
B&H Photo has the new 2014 MacBook Airs on sale for up to $100 off MSRP for a limited time. Shipping is free, and B&H charges NY sales tax only. They also include free copies of Parallels... Read more
Apple 27″ Thunderbolt Display (refurbished) a...
The Apple Store has Apple Certified Refurbished 27″ Thunderbolt Displays available for $799 including free shipping. That’s $200 off the cost of new models. Read more
WaterField Designs Unveils Cycling Ride Pouch...
High end computer case and bag maker WaterField Designs of San Francisco now enters the cycling market with the introduction of the Cycling Ride Pouch – an upscale toolkit with a scratch-free iPhone... Read more
Kingston Digital Ships Large Capacity Near 1T...
Kingston Digital, Inc., the Flash memory affiliate of Kingston Technology Company, Inc.,has announced its latest addition to the SSDNow V300 series, the V310. The Kingston SSDNow V310 solid-state... Read more
Apple’s Fiscal Third Quarter Results; Record...
Apple has announced financial results for its fiscal 2014 third quarter ended June 28, 2014, racking up quarterly revenue of $37.4 billion and quarterly net profit of $7.7 billion, or $1.28 per... Read more
15-inch 2.0GHz MacBook Pro Retina on sale for...
B&H Photo has the 15″ 2.0GHz Retina MacBook Pro on sale for $1829 including free shipping plus NY sales tax only. Their price is $170 off MSRP. B&H will also include free copies of Parallels... Read more

Jobs Board

Sr. Project Manager for *Apple* Campus 2 -...
…the design and construction of one building or building components of the New Apple Campus located in Cupertino, CA. They will provide project management oversight for Read more
WW Sales Program Manager, *Apple* Online St...
**Job Summary** Imagine what you could do here. At Apple , great ideas have a way of becoming great products, services, and customer experiences very quickly. Bring Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Project Manager / Business Analyst, WW *Appl...
…a senior project manager / business analyst to work within our Worldwide Apple Fulfillment Operations and the Business Process Re-engineering team. This role will work Read more
Sr. Manager, *Apple* Deployment Programs fo...
**Job Summary** Apple is seeking candidates for a new position on the Education Content and Technology team. iPad and Mac is in the hands of millions of teachers and Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.