index int64 0 4.08k | text stringlengths 34 4.9k ⌀ | url stringclasses 38
values |
|---|---|---|
196 | Solution
The following solutions will enumerate all the objects directly under an OU. Refer to
“Discussion” section for more on how to display all objects under an OU regardless of
the number of objects involved.
Using a graphical user interface
1. Open the ADUC snap-in (dsa.msc).
2. If you need to change domains, righ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
197 | subtree scope, which is the default search scope for AdFind and DSQuery. If you want
to return all objects regardless of depth, including the OU being searched, simply omit
the -scope switch entirely.
To save on typing, you can use the -default switch with AdFind, which automatically
uses the Domain DN as its search ba... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
198 | 4. Highlight all the objects in the right pane and press the Delete key on your keyboard.
5. Press F5 to refresh the contents of the OU. If objects still exist, repeat step 4.
Using a command-line interface
To delete all objects within an OU, but not the OU itself, you need to use the -subtree
and -exclude options with... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
199 | Solution
Using a graphical user interface
1. Open the ADUC snap-in (dsa.msc).
2. If you need to change domains, right-click on Active Directory Users and Com‐
puters in the left pane, select Change Domain, enter the domain name, and click
OK.
3. In the left pane, browse to the OU you want to delete, right-click on it, ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
200 | In Windows Server 2008 R2 and Windows Server 2012, the Active Di‐
rectory Users and Computers console adds an option to the delete con‐
firmation prompt to use the Delete Subtree server control. By using the
control, you can delete all child objects in an OU, even if the objects are
protected from accidental deletion.
... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
201 | Using PowerShell
To move all users from the Test OU to the Test2 OU using PowerShell, use the following
command:
Get-ADObject -Filter {(ObjectClass -eq "User") -and↵
(ObjectCategory -eq "Person")} -SearchBase "ou=test,dc=adatum,dc=com" |↵
Move-ADObject -TargetPath "ou=test2,dc=adatum,dc=com"
Discussion
When you move ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
202 | Using a graphical user interface
If you want to move more than 2,000 objects at one time, you will need to modify the
default number of objects displayed, as described in the “Discussion” section of
Recipe 5.4.
Using a command-line interface
AdMod will move only 10 objects at a time by default. To move more objects tha... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
203 | If you wish to move an OU with AdMod, use the following syntax:
> admod -b "<OrgUnitDN>" -move "<NewParentDN>"
Using PowerShell
To move the Test OU to the Test2 OU, use the following command:
Move-ADObject -Identity "ou=test,dc=adatum,dc=com"↵
-TargetPath "ou=test2,dc=adatum,dc=com"
Discussion
One of the benefits of A... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
204 | 4. Right-click on the OU and select Rename.
5. Type in the new name for the OU and press Enter.
Using a command-line interface
To rename an object using the built-in DSMove utility, use the following syntax:
> dsmove "<ObjectDN>" -newname "<NewName>"
To use admod, use the following:
> admod -b "<ObjectDN>" -rename "<Ne... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
205 | Using a graphical user interface
1. Open the ADUC snap-in (dsa.msc).
2. If you need to change domains, right-click on Active Directory Users and Com‐
puters in the left pane, select Change Domain, enter the domain name, and click
OK.
3. In the left pane, browse to the OU you want to modify.
4. Right-click on the OU and... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
206 | 5.11. Determining Approximately How Many Child
Objects an OU Has
Problem
You want to quickly determine a rough approximation of how many child objects, if
any, an OU contains.
Solution
Using a graphical user interface
1. Open LDP.
2. From the Menu, select Browse→Search.
3. For Base DN, enter <OrgUnitDN>.
4. For Filter,... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
207 | Using PowerShell
You can retrieve the number of child objects that are contained in an OU by using the
following PowerShell command:
Get-ADObject -SearchBase "ou=test,dc=adatum,dc=com" -Filter * |↵
Measure-Object | FL Count
Discussion
The msDS-Approx-Immed-Subordinates attribute was introduced in Windows Server
2003. ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
208 | 2. If you need to change domains, right-click on Active Directory Users and Com‐
puters in the left pane, select Change Domain, enter the domain name, and click
OK.
3. In the left pane, browse to and select the target OU, and then select Delegate Control.
4. Click Next and then click Add to select the users and/or grou... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
209 | 2. If you need to change domains, right-click on Active Directory Users and Com‐
puters in the left pane, select Change Domain, enter the domain name, and click
OK.
3. Locate the OU in the left pane and then right-click on the OU and select Properties.
4. Select the Managed By tab.
5. Click the Change button.
6. Locate... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
210 | 5.14. Linking a GPO to an OU
Problem
You want to apply the settings in a GPO to the users and/or computers within an OU,
also known as linking the GPO to the OU.
Solution
Using a graphical user interface
1. Open the Group Policy Management snap-in (gpmc.msc).
2. Expand Forest in the left pane.
3. Expand Domains, expand... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
211 | [LDAP://cn={6AC1786C-016F11D2-945F-00C04fB984F9},cn=policies,cn=system,dc=adatum,dc=com;0]
See Also
Recipe 9.14 for more information on the Group Policy Management snap-in
5.15. Protecting an OU Against Accidental Deletion
Problem
You want to prevent an organizational unit object from being accidentally deleted.
Solut... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
212 | being deleted by means of a “fat-finger” deletion. By default, all new OUs that are created
via the Active Directory Users and Computers MMC will have this protection enabled;
however, any preexisting OUs or OUs created through other methods will not unless
you enable it manually using one of the methods shown in this ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
213 | null | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
214 | CHAPTER 6
Users
6.0. Introduction
User accounts are some of the most frequently used objects in Active Directory; they
create the means of authenticating and authorizing someone to access resources on your
network. Because Windows server systems authenticate and authorize users primarily
through Active Directory, many ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
215 | Attribute Description
homeDirectory Local or UNC path of user’s home directory. See Recipe 6.31 for more information.
homeDrive Defines the drive letter to map the user’s home directory to. See Recipe 6.31 for more
information.
lastLogon The last time that a user logged on to a particular DC. This information is not re... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
216 | Attribute Description
msDSFailedInteractiveLogonCoun
tAtLastSuccessfulLogon
New since Windows Server 2008. Indicates the number of failed interactive logons for
a user account since the last time the user successfully logged on interactively.
msDSLastFailedInteractiveLogon
Time
New since Windows Server 2008. Indicate... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
217 | Using PowerShell
To modify display specifiers using PowerShell, run the following command:
Set-ADObject↵
-Identity "cn=user-Display,cn=409,cn=DisplaySpecifiers,cn=configuration,↵
dc=adatum,dc=com"; -Add @{createDialog="%<sn>, %<givenname>"}
Discussion
When you create a new user object in ADUC or ADAC, it will automati... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
218 | 4. The two required fields are Full Name and sAMAccountName. The Full Name field
will automatically be populated if you enter at least a first or a last name. Fill out
any of the remaining fields and then click OK to complete the new-user creation.
Using a command-line interface
You can create a user with the built-in ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
219 | Using PowerShell
When using the New-ADUser cmdlet, there are about 50 common switches that can be
used. In addition, you can specify the –OtherAttributes switch to set less common
attributes. Here is a list of some of the common switches:
• -Name
• -AccountPassword
• -City
• -Company
• -Department
• -Description
• -Dis... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
220 | Solution
Using a command-line interface
The following example uses a for do loop in combination with dsadd to create 1,000
users under the bulk OU in the adatum.com domain with usernames following the
naming convention of User1, User2, User3, etc. The password is set, but other attributes
are not configured. However, y... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
221 | a graphical user interface. You can also modify the examples to pull real data from a
data source, such as an employee database.
Using a command-line interface
The AdMod syntax makes use of the -adau shortcut, which will add X number of users
with Y as their starting password, so that "-adau:4000;MyPassword1" will crea... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
222 | 6. Click Finish.
Using a command-line interface
DSAdd does not support creating inetOrgPerson objects, so use ldifde or AdMod in‐
stead. First, you need to create an LDIF file called create_inetorgperson.ldf with the
following contents:
dn: <UserDN>
changetype: add
objectclass: inetorgperson
sAMAccountName: <UserName>
... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
223 | be losing any information or functionality because the inetOrgPerson class inherits
directly from the user class. For this reason, the inetOrgPerson class has even more
attributes than the Microsoft user class.
The one potential downside is that some of the Microsoft tools, such as the DS utilities,
do not support modi... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
224 | Using a command-line interface
To convert a user object to an inetOrgPerson object, use the following syntax:
> admod -b "<UserDN>" objectClass:+:inetOrgPerson
To revert the object back to a regular user, replace + with - in the pre‐
vious syntax.
Using PowerShell
To convert a user object to an inetOrgPerson object, us... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
225 | 6.6. Modifying an Attribute for Several Users at Once
Problem
You want to modify an attribute for several users at once.
Solution
Using a graphical user interface
1. Open the ADUC snap-in (dsa.msc).
2. If you need to change domains, right-click on Active Directory Users and Com‐
puters in the left pane, select Change D... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
226 | Within ADUC, it may appear that you are limited to modifying multiple users that reside
in the same container. However, you can create a saved query that returns users based
on any criteria you specify. You can then highlight those users and modify them as
described in the GUI solution.
With the CLI solution, you can m... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
227 | Discussion
This recipe covers deleting individual users. If you want to delete a container or OU
and all the objects in it, take a look at Recipe 4.25.
Using PowerShell
Using the –Confirm:$False parameter allows the deletion to occur without a confir‐
mation message from PowerShell.
See Also
Recipe 4.25 for deleting a ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
228 | > admod -b "<UserDN>" <attribute>::<NewValue>
Using PowerShell
To modify user profile attributes using PowerShell, use the following syntax:
Set-ADUser -Identity "<User DN>" -HomeDirectory "<HomeDir>"↵
-HomeDrive "<DriveLetter>" -ProfilePath "<ProfilePath>"↵
-ScriptPath "<ScriptPatch>"
Discussion
The four attributes ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
229 | 3. In the left pane, right-click on the domain and select Find.
4. Type the name of the user and click Find Now.
5. In the Search Results window, right-click on the user and select Move.
6. Browse to and select the new parent container or OU.
7. Click OK.
You can also drag and drop objects from one container or OU into... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
230 | 6.10. Redirecting Users to an Alternative OU
Problem
You want to redirect all new users from the default location (cn=Users) into a different
location that you specify.
Solution
Using a graphical user interface
1. Open LDP.
2. From the menu, select Connection→Connect.
3. For Server, enter the name of a domain controlle... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
231 | 16. Click the Run button.
17. The result of the operations will be displayed in the right pane of the main LDP
window.
Using the command-line interface
To redirect the default OU that new users will be created into, use the following syntax:
> redirusr "<DestinationDN>"
Discussion
Most modern methods for creating user ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
232 | 4. In the Search Results window, right-click on the user and select Rename.
5. You can modify the Full Name, First Name, Last Name, Display Name, User Logon
Name, and User Logon Name (pre-Windows 2000) fields.
6. Click OK after you are done.
Using a command-line interface
The following command will rename the RDN of th... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
233 | While this example may be contrived, it shows that renaming Joe Smith to Joe Einstein
can take up to five attribute changes in Active Directory, or more if you include updates
to proxy addresses and other attributes that are typically tied to the user’s name. It is
also important to note that if you change any of the f... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
234 | Discussion
Copying a user consists of copying the attributes that are common among a certain user
base, which can include department, address, and perhaps even organizational infor‐
mation. ADUC actually uses attributes that are marked in the schema as “Copied when
duplicating a user” to determine which attributes to c... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
235 | The lockoutTime attribute is populated with a timestamp when a user is locked. One
way to find locked-out users would be to find all users that have something populated
in lockoutTime (i.e., lockoutTime=*). That query would definitely find all the currently
locked users, but it would also find all the users that subseq... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
236 | 6. Click the Account tab and then click Unlock account.
7. Click OK.
Using a command-line interface
To unlock all locked user accounts in your domain, use unlock.exe with the following
syntax:
> unlock . *
To unlock a specific user object, replace * with the user’s sAMAccountName or distin‐
guished name, as follows:
> ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
237 | Solution
Using a graphical user interface
LockoutStatus is a program available for Windows that can help identify the domain
controller that handled the lockout. It works by querying the lockout status of a user
against all domain controllers in the user’s domain.
To determine the lockout status of a user:
1. Launch Lo... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
238 | extremely useful when troubleshooting user account lockouts, for example, by de‐
termining which computer is causing the account lockout.
All the Account Lockout tools are available for download from the Microsoft Download
Center.
See Also
Account Lockout Best Practices White Paper and Troubleshooting Account Lockout
t... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
239 | $DOMAIN = Get-ADObject "dc=adatum,dc=com" -Properties *
$MAXPWDAGE = [System.TimeSpan]::FromTicks([System.Math]↵
::ABS($DOMAIN.maxPwdAge)).Days
$MINPWDAGE = [System.TimeSpan]::FromTicks([System.Math]↵
::ABS($DOMAIN.minPwdAge)).Days
$LOCKOUTDURATION =↵
; [System.TimeSpan]::FromTicks([System.Math]::ABS($DOMAIN.lockoutDur... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
240 | Password must meet complexity requirements
If enabled, passwords must meet all of the following criteria:
• Not contain all or part of the user’s account name
• Be at least six characters in length
• Contain characters from three of the following four categories:
a. English uppercase characters (A–Z)
b. English lowerca... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
241 | 6.17. Applying a Fine-Grained Password Policy to a
User Object
Problem
You want to apply a Fine-Grained Password Policy (FGPP) to a user object.
Solution
Using a graphical user interface (steps specific to Windows Server 2012)
1. Open Active Directory Administrative Center.
2. In the top-left pane, click the tree view ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
242 | switch. The full syntax for psomgr.exe can be obtained by typing psomgr.exe /? at a
command prompt, or by visiting the joeware website.
See Also
Chapter 9
6.18. Viewing the Fine-Grained Password Policy That Is in
Effect for a User Account
Problem
You want to determine which FGPP is in effect for a particular user.
Solu... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
243 | Discussion
Within a domain, each user object contains a constructed backlink attribute called
msDS-ResultantPSO that indicates which PasswordSettingsObject is in effect for that
user. The precedence rules for PasswordSettingsObjects are as follows:
1. If a PSO has been applied directly to the user object, this PSO will... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
244 | 6. Click OK.
Using a command-line interface
To enable a user, use the following command:
> dsmod user "<UserDN>" -disabled no
To disable a user, use the following command:
> dsmod user "<UserDN>" -disabled yes
Using PowerShell
To use PowerShell to enable or disable a user account, use the following syntax:
Set-ADUser "... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
245 | 3. Right-click on the domain and select Find.
4. In the Find dropdown box, select Common Queries.
5. Click the “Disabled accounts” option box.
6. Click the Find Now button.
Using a command-line interface
You can enumerate all disabled user objects in your domain by using the built-in
DSQuery utility, as follows:
> dsqu... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
246 | 6.21. Viewing a User’s Group Membership
Problem
You want to view the group membership of a user.
Solution
Using a graphical user interface
1. Open the ADUC snap-in (dsa.msc).
2. In the left pane, right-click on the domain and select Find.
3. Select the appropriate domain.
4. Type the name of the user beside Name and cl... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
247 | Using PowerShell
Get-ADUser "<User DN>" -Properties MemberOf | select -ExpandProperty MemberOf
Discussion
The memberOf attribute on user objects is multivalued and contains the list of distin‐
guished names for groups of which the user is a member. memberOf is actually linked
with the member attribute on group objects,... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
248 | 7. Highlight all groups listed in the Member Of tab and select Remove. Click Yes to
confirm.
8. Click OK.
Using a command-line interface
You can accomplish this task at the command line using a combination of AdFind and
AdMod:
> adfind -b <DomainDN> -f member=<UserDN> -dsq | admod member:-:<UserDN> -unsafe
Using PowerS... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
249 | 3. Select the appropriate domain.
4. Type the name of the user beside Name and click Find Now.
5. In the Search Results window, double-click on the user.
6. Click the Member Of tab.
7. Click on the name of the group you want to set as the primary group.
8. Click the Set Primary Group button.
9. Click OK.
Using PowerShe... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
250 | 6.24. Copying a User’s Group Membership to Another User
Problem
You want to copy one user’s group membership to another user.
Solution
Using a graphical user interface
1. Open the ADUC snap-in (dsa.msc).
2. In the left pane, right-click on the domain and select Find.
3. Select the appropriate domain.
4. Beside Name, ty... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
251 | > adfind -b <DomainDN> -f member=<Source User DN> -dsq |↵
admod member:+:<Dest. UserDN> -unsafe
Using PowerShell
To copy group memberships using PowerShell, use the following syntax:
$SOURCE=Get-ADUser -Identity "<SourceUserDN>" -Properties *
$DESTINATION="<DestinationUserDN>"
foreach ($group in $SOURCE.MemberOf)
{
Ad... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
252 | Solution
Using a graphical user interface
1. Open the ADUC snap-in (dsa.msc).
2. In the left pane, right-click on the domain and select Find.
3. Select the appropriate domain.
4. Type the name of the user beside Name and click Find Now.
5. In the Search Results window, right-click on the user and select Reset Password.... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
253 | Set-ADAccountPassword -Identity "<UserDN>" -Reset↵
-NewPassword (ConvertTo-SecureString -AsPlainText "<NewPassword>" -Force)
See Also
MS KB 225511 (New Password Change and Conflict Resolution Functionality in Win‐
dows); MSDN: IADsUser::SetPassword; MSDN: IADsUser::Change-Password
6.26. Preventing a User from Changing... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
254 | Password ACEs on the target user object. One deny ACE is for the Everyone account
and the other is for Self.
To perform this change across multiple users, you can multiselect users in Active Di‐
rectory Users and Computers and then perform the remaining steps in the GUI solution.
See Also
“How to use the UserAccountCon... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
255 | Using PowerShell
To flag a user’s password to change on next logon with PowerShell, use the following
syntax:
Set-ADUser -Identity <UserDN> -ChangePasswordAtLogon $True
Discussion
Be careful when forcing users to change their password at next logon by using the
PowerShell solution. Active Directory Users and Computers ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
256 | Discussion
Setting a user’s password to never expire overrides any password-aging policy you’ve
defined in the domain. To disable password expiration, you need to set the bit equivalent
of 65,536 (i.e., 10000000000000000) in the userAccountControl attribute of the target
user.
See Also
Recipe 4.15 for more on modifying... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
257 | accounts, you’ll need to develop your own user password expiration notification pro‐
cess. Even in a pure Windows environment, cached logins present a problem because
when a user logs in to the domain with cached credentials (i.e., when the client is not
able to reach a domain controller), this password expiration noti... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
258 | 5. View the value of msDS-RevealedDSAs to view the RODCs that have cached the
user’s password.
6. Click OK or Cancel to close the Properties window.
Using a command-line interface
> adfind -b <UserDN> msDS-RevealedDSAs
Using PowerShell
> Get-ADUser -Identity "<UserDN>" -Properties "msDS-RevealedDSAs" |↵
FL msDS-Reveal... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
259 | 2. In the left pane, right-click on the domain and select Find.
3. Select the appropriate domain.
4. Beside Name, type the name of the user and click Find Now.
5. In the Search Results window, double-click on the user.
6. Select the Account tab.
7. Many of the userAccountControl flags can be set under Account options.
... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
260 | The userAccountControl attribute is a bit flag, which means you have to take a couple
of extra steps to search against it or modify it. See Recipe 4.12 for more on searching
with a bitwise filter and Recipe 4.15 for modifying a bit flag attribute.
The dsmod user command can be used to modify a subset of userAccountCont... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
261 | See Also
Recipe 4.12; Recipe 4.15 for setting a bit flag attribute; “How to use the UserAccount‐
Control flags to manipulate user account properties”
6.32. Setting a User’s Account to Expire
Problem
You want a user’s account to expire at some point in the future.
Solution
Using a graphical user interface
1. Open the AD... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
262 | intervals since January 1, 1601. If you set this attribute to 0, it disables account expiration
for the user (i.e., the account will never expire). Note that this is different from the dsmod
user command, where a value of 0 with -acctexpires will cause the account to expire
at the end of the day.
See Also
MSDN: Account... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
263 | Discussion
Trying to determine when a user last logged on has always been a challenge in the
Microsoft NOS environment. In Windows NT, you could retrieve a user’s last logon
timestamp from a PDC or BDC, but this timestamp was the last time the user logged
on to the individual PDC or BDC itself. That means to determine ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
264 | Solution
Using a graphical user interface
1. Open the ADUC snap-in (dsa.msc).
2. In the left pane, right-click on the domain and select Find.
3. Beside Find, select Common Queries.
4. Select the number of days beside “Days since last logon.”
5. Click the Find Now button.
Using a command-line interface
You can locate us... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
265 | Using PowerShell
PowerShell has a property named LastLogonDate that is a human-friendly conversion
of the lastLogonTimestamp attribute. This allows for easy PowerShell queries involving
finding inactive users.
See Also
Recipe 6.29 for more on computing large integer timestamps; Recipe 6.33 for more on
finding a user’s ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
266 | function dump($byte)
{
$result = ""
for ($i = 0; $i -lt 8; $i++)
{
$result += $onoff[($byte -band $pow2[$i]) -ne 0]
}
return $result
}
# days of the week, zero based
$days = @("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",↵
"Friday", "Saturday")
$day = 0
# main
$obj = [ADSI]$userDN
$arr = $obj.logonHours... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
267 | See Also
MS KB 816666 (How to Limit User Logon Time in a Domain in Windows Server 2003);
MSDN: Logon-Hours attribute [AD Schema]
6.36. Viewing a User’s Managed Objects
Problem
You want to view the objects that are managed by a user.
Solution
Using a graphical user interface
1. Open ADSI Edit.
2. If an entry for the nam... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
268 | it, you can use the managedObjects attribute on user, contact, or group objects to get
the list of objects for which the user has been configured in the managedBy attribute.
6.37. Creating a UPN Suffix for a Forest
Problem
You want users to have a different UPN suffix from the default provided by your forest.
Solution
... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
269 | See Also
MS KB 243280 (Users Can Log On Using User Name or User Principal Name); “Add
User Principal Name Suffixes”; MS KB 269441 (How to Use ADSI to List the UPN
Suffixes that Are Defined in Active Directory)
6.38. Restoring a Deleted User
Problem
You want to restore a user object that has been inadvertently deleted.
... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
270 | 6.39. Protecting a User Against Accidental Deletion
Problem
You want to prevent a user object from being accidentally deleted by an administrator
who selects the incorrect option in Active Directory Users and Computers.
Solution
Using a graphical user interface
1. Open Active Directory Users and Computers. Click on Vie... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
271 | null | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
272 | CHAPTER 7
Groups
7.0. Introduction
A group is a simple concept that has been used in many different types of standalone
and networked systems over the years. In generic terms, a group is just a collection of
objects. Groups are often used to apply security in an efficient manner, where you create
a collection of users ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
273 | of domain local groups, a separate forest if a cross-forest trust exists), whereas global
groups can only have members that are part of the same domain that the group is
contained in. When assigning permissions to group objects, universal and global groups
can be assigned permissions to resources anywhere in the forest... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
274 | 7.1. Creating a Group
Problem
You want to create a group.
Solution
Using a graphical user interface
1. Open the Active Directory Administrative Center.
2. In the left pane, click to highlight the desired domain.
3. In the right pane, click New and then click Group.
4. Enter the name of the group, enter the sAMAccountNa... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
275 | Table 7-2. Numeric values for group types
Group type Numeric value
Universal Distribution Group 8
Universal Security Group −2147483640
Domain Local Distribution Group 4
Domain Local Security Group −2147483644
Global Distribution Group 2
Global Security Group −2147483646
These values are defined in the ADS_GROUP_TYPE_EN... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
276 | 7.2. Viewing the Permissions of a Group
Problem
You want to list the AD object permissions that have been assigned to a group object.
Solution
Using a graphical user interface
1. Open the Active Directory Users and Computers (ADUC) snap-in (dsa.msc). Click
on View and ensure that there is a checkmark next to Advanced F... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
277 | Each AD object has a Security Descriptor (SD) associated with it that is made up of a
Discretionary Access Control List (DACL) that dictates which users and groups can
access an object, and a System Access Control List (SACL) that controls which users’ or
groups’ activities should be audited. The DACL and SACL are each... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
278 | Using PowerShell
To enumerate the direct group membership of the Domain Admins group, run the
following PowerShell command:
Get-ADGroupMember -Identity "Domain Admins" | Select Name
Discussion
The member attribute of a group object contains the distinguished names of the direct
members of the group. By direct members, ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
279 | 6. Click the Members tab.
7. Double-click on each group member to view its membership.
Using a command-line interface
> dsget group "<GroupDN>" -members -expand
You can also obtain this information using the joeware MemberOf utility:
> memberof -group <GroupDN>
Using PowerShell
The simplest method of listing nested gro... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
280 | 3. In the left pane, right-click on the domain and select Find.
4. Enter the name of the group and click Find Now.
5. Double-click on the group in the bottom results pane.
6. Click the Members tab.
7. To remove a member, click on the member name, click the Remove button, click
Yes, and click OK.
8. To add a member, cli... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
281 | The benefit of using group objects as a collection mechanism is that the same object can
be a member of multiple groups, whereas an object can only be a part of a single OU.
Another key difference is that you can assign permissions on resources to groups be‐
cause they are considered security principals in Active Direc... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
282 | Discussion
Using a command-line interface
The DSMove utility can work against any type of object, including groups. The first
parameter is the DN of the group that you want to move. The second parameter is the
new parent container of the group. The -s parameter can additionally be used to des‐
ignate a specific server ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
283 | 8. On the Group Options screen, select one or more of the following and click Next:
“Update user rights”
Copies any user rights that are assigned in the source domain to the target
domain.
“Copy group members”
Specifies whether the user objects that belong to the group should be migrated
along with the group. If you do... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
284 | When you convert a group between types, you may encounter problems because dif‐
ferent groups have different membership restrictions. See the Recipe 7.0 section of this
chapter for more information on group type membership restrictions.
Another way to accomplish interdomain (intraforest or interforest) group moves is b... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
285 | > admod -b "<GroupDN>" groupType::<GroupType>
Just as when you created a group using AdMod, you must specify the numeric value for
the group type. Refer to Recipe 7.1 for more information.
Using PowerShell
To modify a group’s type or scope with PowerShell, use the following syntax. Use
'Security' or 'Distribution' as t... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
286 | 2. In the right pane, enter the name of the group in the Global Search box, select the
desired domain in the scope, and then click the search icon.
3. In the search results pane, double-click the group to display the group properties.
4. Scroll down to the Extensions section and then click the Attribute Editor tab.
5. ... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
287 | {-addmbr | -rmmbr | -chmbr} <MemberDN1> <MemberDN2>
Adds the specified objects to the group (addmbr), removes the specified objects
(rmmbr), or replaces the membership list wholesale with only the specified objects
(chmbr)
Using PowerShell
You can modify a group’s properties by using the Set-ADGroup cmdlet, as shown in... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
288 | See Also
Recipe 4.14; Recipe 4.28
7.10. Delegating Control for Managing Membership
of a Group
Problem
You want to delegate the ability to manage the membership of a group.
Solution
Using a graphical user interface
1. Open the ADUC snap-in (dsa.msc).
2. If you need to change domains, right-click on Active Directory User... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
289 | Using PowerShell
In PowerShell, you can change the person or group who is listed as the manager of a
group. However, note that the following example does not set the permissions for the
manager to manage the group’s membership:
Set-ADGroup <Group Name> -ManagedBy "<GroupDN>"
You can use a PowerShell console on a comput... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
290 | 2. If you need to change domains, right-click on Active Directory Users and Com‐
puters in the left pane, select Connect to Domain, enter the domain name, and click
OK.
3. In the left pane, right-click on the domain and select Find.
4. Type the name of the user and click Find Now.
5. In the Search Results window, doubl... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
291 | Using PowerShell
The PowerShell solution uses the calculated property named PrimaryGroup, which
allows the solution to be straightforward and similar to querying for typical user
attributes.
See Also
MS KB 297951 (How to Use the PrimaryGroupID Attribute to Find the Primary Group
for a User)
7.12. Enabling Universal Gro... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
292 | dn: cn=NTDS Site Settings,cn=<SiteName>,cn=sites,cn=configuration,<ForestRootDN>
changetype: modify
replace: options
options: 32
-
Then use the following command to import the change:
> ldifde -i -f enable_univ_cache.ldf
You can also perform this change in the adatum.com domain by using AdMod with the
following syntax:... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
293 | universal group information locally, thus removing the need to query the global catalog
during client logon.
You can enable universal group caching manually by enabling the 10000 bit (32 in
decimal) on the options attribute of the NTDS Site Settings object. See Recipe 4.15
for more information on properly setting a bit... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
294 | Using PowerShell
To restore the group object and membership, use the following PowerShell command
syntax:
Get-ADObject -Filter {isDeleted -eq $true} -IncludeDeletedObjects |↵
Where-Object {$_.DistinguishedName -match "<GroupName>"} |↵
Restore-ADObject
Discussion
Prior to the introduction of the Active Directory Recyc... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
295 | 3. Right-click on the group that you want to modify and click Properties.
4. Click on the Object tab.
5. Place a checkmark next to “Protect object from accidental deletion.”
6. Click OK.
Using a command-line interface (all versions)
dsacls "<GroupDN>" /d EVERYONE:SDDT
Using PowerShell (all versions)
Set-ADObject "<Grou... | http://ter40.free.fr/ebooktmp/new/Active%20Directory%20Cookbook,%204th%20Edition.pdf |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.