Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


December 2006

Using Dsmod To Update a Large Number of User Records at One Time


RSS
Subscribe to Windows IT Pro | See More Active Directory (AD) Articles Here | Reprints
Or get the Monthly Online Pass—only $5.95 a month!
Main Article    Ask the Experts

I'm using Windows Server 2003's Dsmod command to modify user accounts in Active Directory (AD). Can I use a wildcard character as part of the target object?

No you can't use wildcard characters with Dsmod. But I can show you a way to work around this. Ordinarily when using the Dsmod utility, you pass one or more target objects, separated by a space. So for example to update the passwords for Bruce Wayne and Clark Kent, I would type the command

 dsmod user “cn=bruce wayne,
  ou=JusticeLeague,dc=r2demo,
  dc=test” “cn=clark kent,
  ou=JusticeLeague,dc=r2demo,
  dc=test” -pwd Pa55word

And the system should return

dsmod succeeded:cn=bruce wayne,
  ou=JusticeLeague,dc=r2demo,
  dc=test
dsmod succeeded:cn=clark kent,
  ou=JusticeLeague,dc=r2demo,
  dc=test

Now, lets say that I have 500 objects in an organizational unit (OU) and I want to update all of them. Instead of passing 500 distinguished names (DNs), one for each object, it would be much easier to pass a wildcard character as part of the target object name (e.g., *,ou=JusticeLeague,dc=r2demo,dc=test), but unfortunately, Dsmod doesn't support it. However, Windows does support the concept of piping output from one command as the input of another command, which you denote by using the pipe (|) character. Therefore, you can use another command whose output is a list of the DNs of the objects in the specified OU, as the equivalent of the wildcard. For example, to return a lis of all user type objects in the JusticeLeague OU, use the Dsquery command as follows:

dsquery user ou=JusticeLeague,
  dc=r2demo,dc=test

and the system would return

“CN=Bruce Wayne,OU=JusticeLeague,
  DC=r2demo,DC=test”
“CN=Clark Kent,OU=JusticeLeague,
  DC=r2demo,DC=test”
“CN=Diana Prince,OU=JusticeLeague,
  DC=r2demo,DC=test”
“CN=Hal Jordan,OU=JusticeLeague,
  DC=r2demo,DC=test”
“CN=Arthur Curry,OU=JusticeLeague,
  DC=r2demo,DC=test”
“CN=Wally West,OU=JusticeLeague,
  DC=r2demo,DC=test”

Now if you combine the Dsmod and Dsquery commands, as the following example shows, you can perform modifications on all the users in the OU.

dsquery user ou=JusticeLeague,
  dc=r2demo,dc=test| dsmod user
  -pwd Pa55word

Now suppose you want to update only users in a certain group. For that task, you'd use the Dsget command to list all members of a given group and then pipe the output to the Dsmod command, as the following command shows:

dsget group “cn=members,
  ou=JusticeLeague,dc=r2demo,
  dc=test” -members| dsmod user
  -pwd Pa55word

When you combine the power of Dsquery and Dsget, you can do far more than with a wildcard character, leading to very granular search outputs that you can use as input to your modification requirements. You're limited only by your skill with the Dsquery and Dsget commands.

End of Article



Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...

VMware and the Future of Virtualization

What's next for virtualization and business IT? Windows IT Pro senior editor Jeff James speaks with VMware President and CEO Diane Greene on the future of virtualization technology. ...

Common .pst File Questions

Sue Mosher addresses some of the inevitable questions that Outlook users eventually ask about Personal Folders (.pst) files. ...


Active Directory (AD) Whitepapers An Introduction to Windows Server 2008 Server Manager

Get More from Active Directory—Easily Audit Changes, and Secure and Restore Objects

User Provisioning: Get the Most Bang for your IT Buck

Related Events Check out our list of Free Email Newsletters!

Active Directory (AD) eBooks Keeping Your Business Safe from Attack: Monitoring and Managing Your Network Security

A Guide to Group Policy

Windows 2003: Active Directory Administration Essentials

Related Active Directory (AD) Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

Critical Challenges of ESI & Email Retention
Are you storing too much electronic information? Get expert legal advice and better understanding of what you are required to do as an IT professional.

Become a fan of Windows IT Pro on Facebook!
Join us on Facebook and be a fan of Windows IT Pro!

Sustainable Compliance: Are You Having a Resource Crisis?
Read this white paper to examine trends in compliance and security management and review approaches to reducing the cost and operational burden of compliance.

Rev Up Your IT Know-How with Our Recharged Magazine!
The improved Windows IT Pro provides trusted IT content with an enhanced new look and functionality! Get comprehensive coverage of industry topics, expert advice, and real-world solutions—PLUS access to over 10,000 articles online. Order today!

Get It All with Windows IT Pro VIP
Stock your IT toolbox with every solution ever printed in Windows IT Pro and SQL Server Magazine plus bonus Web-exclusive content on hot topics. Subscribe to receive the VIP CD and a subscription to your choice of Windows IT Pro or SQL Server Magazine!



Order Your Fundamentals CD Today!
Gain an introduction to Exchange, learn server security requirements, and understand how unified communications can play a role in your messaging strategies with this free Exchange CD.
Windows IT Pro Home Register About Us Affiliates / Licensing Media Kit Contact Us/Customer Service  
SQL Connected Home IT Library SuperSite FAQ Wininfo News
Europe Edition Office & SharePoint Pro Windows Dev Pro Windows Excavator 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing