Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Script sur compte AD

1 réponse
Avatar
OlivierT
Bonjour,

Je travaille avec un AD 2003. J'ai besoin de modifier une liste de compte
utilisateur. La modification consiste en :
* Décocher l'option "Password never expired"
* Décocher "Password must be changed on next logon"

Le reste des options ne doit pas être modifié.

Comment puis-je faire ces modification en script ?

Merci de votre aide,

Olivier

1 réponse

Avatar
Anthony Houssa
Bonsoir,

Je vous conseille de vous inspirer des scripts suivants du Microsoft Script
center (l'édition portable peut être téléchargée ici:
http://www.microsoft.com/downloads/details.aspx?FamilyID´cb2678-dafb-4e30-b2da-b8814fe2da5a&DisplayLang=en):
"Modify a Local User Account Password So It Never Expires" et
"Enable Users to change their password".
(j'ai copié les exemples ci-dessous)

Pour des informations plus complètes concernant les descripteurts de
sécurité, je vous conseille de télécharger l'excellent white paper de
Microsoft (malheureusement uniquement disponible en Anglais): "Scripting
Security descriptors"
http://www.google.be/url?sa=t&source=web&ct=res&cd=3&ved BAQFjAC&url=http%3A%2F%2Fdownload.microsoft.com%2Fdownload%2Fa%2F1%2Fa%2Fa1afc045-4b65-4a0a-817c-9110b99f542d%2FScripting_Security_Descriptors.doc&rct=j&q=site%3Amicrosoft.com+ACTIVE+DIRECTORY+security+descriptor++scripting&ei=ZdXdS5jIG4bt-AaWlpWKBw&usg¯QjCNH9eUJIoDE6_INTijKu9XwnmhId_w

Bien à vous,
Anthony Houssa
_____________________________________________________________________

"Modify a Local User Account Password So It Never Expires"

Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000

strDomainOrWorkgroup = "Fabrikam"
strComputer = "atl-win2k-01"
strUser = "KenMeyer"

Set objUser = GetObject("WinNT://" & strDomainOrWorkgroup & "/" & _
strComputer & "/" & strUser & ",User")

objUserFlags = objUser.Get("UserFlags")
objPasswordExpirationFlag = objUserFlags OR ADS_UF_DONT_EXPIRE_PASSWD
objUser.Put "userFlags", objPasswordExpirationFlag
objUser.SetInfo

_____________________________________________________________________

"Enable Users to change their password"

Const ADS_ACETYPE_ACCESS_DENIED_OBJECT = &H6
Const CHANGE_PASSWORD_GUID = _
"{ab721a53-1e2f-11d0-9819-00aa0040529b}"

Set objUser = GetObject _
("LDAP://cn=myerken,ou=management,dcúbrikam,dc=com")
Set objSD = objUser.Get("nTSecurityDescriptor")
Set objDACL = objSD.DiscretionaryAcl
arrTrustees = Array("nt authorityself", "everyone")

For Each strTrustee In arrTrustees
For Each ace In objDACL
If(LCase(ace.Trustee) = strTrustee) Then
If((ace.AceType = ADS_ACETYPE_ACCESS_DENIED_OBJECT) And _
(LCase(ace.ObjectType) = CHANGE_PASSWORD_GUID)) Then
objDACL.RemoveAce ace
End If
End If
Next
Next

objUser.Put "nTSecurityDescriptor", objSD
objUser.SetInfo




"OlivierT" wrote in message
news:
Bonjour,

Je travaille avec un AD 2003. J'ai besoin de modifier une liste de compte
utilisateur. La modification consiste en :
* Décocher l'option "Password never expired"
* Décocher "Password must be changed on next logon"

Le reste des options ne doit pas être modifié.

Comment puis-je faire ces modification en script ?

Merci de votre aide,

Olivier