The scope g parameter tells the tool to create a global group. Next, we use the Dsquery and Dsmod combination to add all the MyOU members to the new group:
dsquery user -scope onelevel
"ou=MyOU,DC=LissWare,DC=Net"
| dsmod group "cn=MyGroup,
ou=MyOU,DC=LissWare,DC=Net"
-addmbr
Moving Users with Dsmove
Now imagine that you want to move certain users to a specific OU or container. For instance, to move user John Conner from MyOU to the Users container, the command would be:
dsmove "cn=Connor John,OU=MyOU,
DC=LissWare,DC=Net"
-newparent "cn=Users,
DC=LissWare,DC=Net"
But what if we wanted to move all the users whose first name starts with J? We can do this by combining the Dsquery and Dsmove tools. To find all the users whose first name starts with J, you might try the command
dsquery user -name J*
Unfortunately, this command doesn't return the expected results because the -name switch performs a match on the relative DN of the user (i.e., the common name, or cn,) and we built the DN with the last name in the first position and the first name in the last position. Therefore, we can't use the standard Dsquery switches; rather, we must explicitly express the LDAP query filter that we want to use. To locate all users that have a first name that starts with J, we need to use the command
dsquery * "ou=MyOU,DC=LissWare,
DC=Net"
-filter "(&(objectClass=user)
(givenName=J*))"
This filter returns three DNs: Jane, John, and Juliet. To carry out the move operation, we combine the above query with the appropriate Dsmove command, as follows: . . .
NOT happy...
nbmi-it June 22, 2006 (Article Rating: