OVH Cloud OVH Cloud

modifier option d'un compte AD

12 réponses
Avatar
Nico
Bonjour =E0 tous,

J'ai un soucis avec un script pour cr=E9er des utilisateurs=20
sous active directory. Enfin ce n'est pas pour la cr=E9ation=20
proprement dite, mais plutot pour la modification des=20
options du compte.=20
Je souhaiterais que le mot de passe n'expire jamais (=E7a=20
c'est bon cela fonctionne) et que l'utilisateur ne puisse=20
pas changer de mot de passe (mon probl=E8me est l=E0).
Est ce que quelqu'un peut m'aider?

voil=E0 mon script:

wscript.echo "Le script commence. Cliquez OK pour=20
continuer."
DIM arrRecord
Dim Nom, Prenom, CodeUtilisateur
Dim NomScript, userActCtrl
Const ForReading =3D 1

Const ADS_UF_PASSWD_CANT_CHANGE =3D &H40
Const ADS_UF_DONT_EXPIRE_PASSWD =3D &H10000

Nom=3D"AA": Prenom=3D"AAAAAA": CodeUtilisateur=3D"AA_AAAAAA"
NomScript=3D"mon_script.bat"

Set Root =3D GetObject("LDAP://RootDSE")
DomainPath =3D Root.Get("DefaultNamingContext")
Set Domain =3D GetObject("LDAP://" & DomainPath)
Set ou_HR =3D GetObject("LDAP://CN=3DUsers, " & DomainPath)

Set adsUser =3D ou_HR.Create("user", "CN=3D" & Nom & " " &=20
Prenom)
adsUser.Put "sn", Nom=20
adsUser.Put "GivenName", Prenom=20
adsUser.Put "Name", Nom & " " & Prenom=20
adsUser.Put "displayName", Nom & " " & Prenom=20
adsUser.Put "sAMAccountName", CodeUtilisateur '=20
adsUser.Put "userPrincipalName", CodeUtilisateur
adsUser.Put "scriptPath", NomScript =20
adsUser.SetInfo
adsUser.SetPassword "0123456"
adsUser.SetInfo

userActCtrl =3D adsUser.Get("userAccountControl")
userActCtrl =3D userActCtrl xOr ADS_UF_DONT_EXPIRE_PASSWD=20
xOr ADS_UF_PASSWD_CANT_CHANGE
adsUser.Put "userAccountControl", userActCtrl

adsUser.AccountDisabled =3D False
adsUser.SetInfo

Set adsUser =3D Nothing

wscript.echo "Utilisateurs cr=E9=E9s.", Chr(10),Chr
(10),"Cliquez pour finir."

2 réponses

1 2
Avatar
J'ai enfin trouvé et cette fois ci, cela fonctionne:
pour ceux qui ont ce pb, essayer de remplacer la ligne:

arrTrustees = array("nt authorityself", "EVERYONE")

par:

arrTrustees = array("S-1-5-10", "S-1-1-0")


-----Message d'origine-----
Après quelque test, je me suis aperçu qu'effectivement ec
là ne venait pas de cette dll :-(
J'ai repris ma recherche sur internet et j'ai trouvé ceci:

"Note The following code example only works for domains
where the primary language is English, because
the "Everyone" and "NT AUTHORITYSELF" strings are
localized based on the language of the first domain
controller in the domain. There is no way in Visual Basic
to obtain the account names for a well-known security
principal without calling the LookupAccountSid function.
If using Visual Basic, it is suggested that you use the
WinNT provider to determine the User Cannot Change
Password Permission as shown in Reading User Cannot
Change

Password (WinNT Provider)." (trouver à cette @:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/adsi/adsi/reading_user_cannot_change_password_ldap_prov
i

der.asp)



Avatar
Jonathan Bismuth
j'ai été devancé :)

effectivement, le Sid remplace très bien le nom d'utilisateur le cas échéant

--

Jonathan BISMUTH
MCSE (W2K) 2272252
Beta ID 570978
WSH/Batch Scripter
http://www.supinfo-projects.com/fr/authors/?a=Cyber_Hunter
a écrit dans le message de news:
044f01c51019$21abef30$
J'ai enfin trouvé et cette fois ci, cela fonctionne:
pour ceux qui ont ce pb, essayer de remplacer la ligne:

arrTrustees = array("nt authorityself", "EVERYONE")

par:

arrTrustees = array("S-1-5-10", "S-1-1-0")


-----Message d'origine-----
Après quelque test, je me suis aperçu qu'effectivement ec
là ne venait pas de cette dll :-(
J'ai repris ma recherche sur internet et j'ai trouvé ceci:

"Note The following code example only works for domains
where the primary language is English, because
the "Everyone" and "NT AUTHORITYSELF" strings are
localized based on the language of the first domain
controller in the domain. There is no way in Visual Basic
to obtain the account names for a well-known security
principal without calling the LookupAccountSid function.
If using Visual Basic, it is suggested that you use the
WinNT provider to determine the User Cannot Change
Password Permission as shown in Reading User Cannot
Change

Password (WinNT Provider)." (trouver à cette @:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/adsi/adsi/reading_user_cannot_change_password_ldap_prov
i

der.asp)



1 2