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.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

SpamSieve 2.9.38 - Robust spam filter fo...
SpamSieve is a robust spam filter for major email clients that uses powerful Bayesian spam filtering. SpamSieve understands what your spam looks like in order to block it all, but also learns what... Read more
TeamViewer 15.0.8397 - Establish remote...
TeamViewer gives you remote control of any computer or Mac over the Internet within seconds or can be used for online meetings. Find out why more than 200 million users trust TeamViewer! Free for non... Read more
SteerMouse 5.4.3 - Powerful third-party...
SteerMouse is an advanced driver for USB and Bluetooth mice. SteerMouse can assign various functions to buttons that Apple's software does not allow, including double-clicks, modifier clicks,... Read more
Toast Titanium 18.2.1 - The ultimate med...
Roxio Toast Titanium, the leading DVD burner for Mac, makes burning even better, adding Roxio Secure Burn to protect your files on disc and USB in Mac- or Windows-compatible formats. Get more style... Read more
HoudahSpot 5.0.11 - Advanced file-search...
HoudahSpot is a versatile desktop search tool. Use HoudahSpot to locate hard-to-find files and keep frequently used files within reach. HoudahSpot will immediately feel familiar. It works just the... Read more
ClipGrab 3.8.6 - Download videos from Yo...
ClipGrab is a free downloader and converter for YouTube, Vimeo, Facebook and many other online video sites. It converts downloaded videos to MPEG4, MP3 or other formats in just one easy step Version... Read more
ExpanDrive 7.4.0 - Access cloud storage...
ExpanDrive builds cloud storage in every application, acts just like a USB drive plugged into your Mac. With ExpanDrive, you can securely access any remote file server directly from the Finder or... Read more
Adobe Dreamweaver CC 2020 20.0 - Build w...
Dreamweaver CC 2020 is available as part of Adobe Creative Cloud for as little as $20.99/month (or $9.99/month if you're a previous Dreamweaver customer). Adobe Dreamweaver CC 2020 allows you to... Read more
Eye Candy 7.2.3.85 - 30 professional Pho...
Eye Candy renders realistic effects that are difficult or impossible to achieve in Photoshop alone, such as Fire, Chrome, and the new Lightning. Effects like Animal Fur, Smoke, and Reptile Skin are... Read more
Sparkle Pro 2.8.5 - Visual website creat...
Sparkle Pro will change your mind if you thought building websites wasn't for you. Sparkle is the intuitive site builder that lets you create sites for your online portfolio, team or band pages, or... Read more

Latest Forum Discussions

See All

Pre-register for Hello Kitty AR: Kawaii...
Hello Kitty — the cute cat that launched a multi-billion-pound franchise — has been brought to life… sort of. Sanrio has teamed up with the Bublar Group to create a new mobile game that uses AR tech to turn the real world into Hello Kitty’s... | Read more »
Gorgeous and tranquil puzzler Spring Fal...
One-man indie studio SPARSE//GameDev has now launched its tranquil puzzler, Spring Falls. It's described as "a peaceful puzzle game about water, erosion, and watching things grow". [Read more] | Read more »
Black Desert Mobile gets an official rel...
Pearl Abyss has just announced that its highly-anticipated MMO, Black Desert Mobile, will launch globally for iOS and Android on December 11th. [Read more] | Read more »
Another Eden receives new a episode, cha...
Another Eden, WFS' popular RPG, has received another update that brings new story content to the game alongside a few new heroes to discover. [Read more] | Read more »
Overdox guide - Tips and tricks for begi...
Overdox is a clever battle royale that changes things up by adding MOBA mechanics and melee combat to the mix. This new hybrid game can be quite a bit to take in at first, so we’ve put together a list of tips to help you get a leg up on the... | Read more »
Roterra Extreme - Great Escape is a pers...
Roterra Extreme – Great Escape has been described by developers Dig-It Games as a mini-sequel to their acclaimed title Roterra: Flip the Fairytale. It continues that game's tradition of messing with which way is up, tasking you with solving... | Read more »
Hearthstone: Battlegrounds open beta lau...
Remember earlier this year when auto battlers were the latest hotness? We had Auto Chess, DOTA Underlords, Chess Rush, and more all gunning for our attention. They all had their own reasons to play, but, at least from where I'm standing, most... | Read more »
The House of Da Vinci 2 gets a new gamep...
The House of Da Vinci launched all the way back in 2017. Now, developer Blue Brain Games is gearing up to deliver a second dose of The Room-inspired puzzling. Some fresh details have now emerged, alongside the game's first official trailer. [Read... | Read more »
Shoot 'em up action awaits in Battl...
BattleBrew Productions has just introduced another entry into its award winning, barrelpunk inspired, BattleSky Brigade series. Whilst its previous title BattleSky Brigade TapTap provided fans with idle town building gameplay, this time the... | Read more »
Arcade classic R-Type Dimensions EX blas...
If you're a long time fan of shmups and have been looking for something to play lately, Tozai Games may have just released an ideal game for you on iOS. R-Type Dimensions EX brings the first R-Type and its sequel to iOS devices. [Read more] | Read more »

Price Scanner via MacPrices.net

13″ 2.4GHz MacBook Pros available for up to $...
Apple has a full line of Certified Refurbished 2019 13″ 2.4GHz 4-Core Touch Bar MacBook Pros available starting at $1529 and up to $300 off MSRP. Apple’s one-year warranty is included, shipping is... Read more
New at T-Mobile: Switch to T-Mobile, and get...
T-Mobile is offering a free 64GB iPhone 8 for new customers who switch to T-Mobile and open a new line of service. Eligible trade-in required, and discount applied over a 24 month period. The fine... Read more
Xfinity Mobile’s Black Friday Apple savings:...
Take $250 off the purchase of any iPhone at Xfinity Mobile with a new line activation, and transfer of phone number to Xfinity Mobile, through December 8, 2019. This includes Apple’s new iPhone 11... Read more
2019 13″ 1.4GHz MacBook Pros available starti...
Apple has a full line of Certified Refurbished 2019 13″ 1.4GHz 4-Core Touch Bar MacBook Pros available starting at $1099 and up to $230 off MSRP. Apple’s one-year warranty is included, shipping is... Read more
Save up to $350 on a 21″ or 27″ iMac with the...
Apple has Certified Refurbished 2019 21″ & 27″ iMacs available starting at $929 and up to $350 off the cost of new models. Apple’s one-year warranty is standard, shipping is free, and each iMac... Read more
Early Holiday 2019 Sale: B&H again offers...
B&H Photo has 10.2″ iPads on sale again for $30 off Apple’s MSRP, starting at $299, as part of their early Holiday 2019 sale. Overnight shipping is free to many addresses in the US: – 10.2″ 32GB... Read more
Apple iMacs on sale today at B&H Photo fo...
B&H Photo has new 2019 21″ and 27″ 5K iMacs on stock today and on sale for up to $150 off Apple’s MSRP. Overnight shipping is free to many locations in the US. These are the same iMacs sold by... Read more
2018 4 and 6-Core Mac minis on sale today for...
Apple resellers are offering new 2018 4-Core and 6-Core Mac minis for $80-$100 off MSRP for a limited time. B&H Photo has the new 2018 4-Core and 6-Core Mac minis on sale for up to $100 off Apple... Read more
Early Holiday 2019 sale at B&H Photo: 12....
B&H Photo has new 12.9″ iPad Pros on sale for up to $120 off Apple’s MSRP as part of their early Holiday 2019 sale. Overnight shipping is free to many addresses in the US: – 12.9″ 64GB WiFi iPad... Read more
8-Core iMac Pro on sale today for $4499 at B...
B&H Photo has the base 8-Core 3.2GHz 32GB/1TB iMac Pro on sale today for $4499 — $500 off Apple’s MSRP. Shipping is free. Their price is the lowest available for a new iMac Pro from any Apple... Read more

Jobs Board

*Apple* Health Benefit Specialist - Call Cen...
Description ** Apple Health Benefit Specialist - Call Center (MAS 3/MACSC)** **Olympia, WA Multiple Positions** *The ideal candidate for this position will have Read more
Hair Stylist - *Apple* Blossom Mall - JCPen...
Hair Stylist - Apple Blossom Mall Location:Winchester, VA, United States- Apple Blossom Mall 1850 Apple Blossom Dr Job ID:1065040Salon Professionals Job Read more
*Apple* Mobility Pro - Best Buy (United Stat...
**747088BR** **Job Title:** Apple Mobility Pro **Job Category:** Store Associates **Store NUmber or Department:** 000297-Reston-Store **Job Description:** At Best Read more
Nurse Practitioner - Field Based (San Bernard...
Nurse Practitioner - Field Based (San Bernardino, CA, Apple Valley, Hesperia) **Location:** **United States** **Requisition #:** PS30312 **Post Date:** Nov 11, 2019 Read more
Best Buy *Apple* Computing Master - Best Bu...
**747061BR** **Job Title:** Best Buy Apple Computing Master **Job Category:** Store Associates **Store NUmber or Department:** 000647-Kildeer-Store **Job Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.