Question Changer la propriété LDAP user cannot change pswd

Plus d'informations
il y a 17 ans 7 mois #2677 par gregory.ott
Bonjour à tous,

Je cherche le moyen de modifier la propriété : \"user cannot change password\" de certain de mes comptes de service dans l'AD.

J'ai tenté ça :
[code:1]$user = Get-WmiObject Win32_UserAccount -filter \"Name='svc-ww-d-SPInst'\"
$user.passwordchangeable
$user.passwordchangeable = $true
$user.passwordchangeable
$user.put()[/code:1]

et ça me donne ça :
[code:1]C:\Documents and Settings\Administrator\Desktop\Untitled1.ps1
False
True
Exception calling \"Put\" with \"0\" argument(s): \"Generic failure \"
At C:\Documents and Settings\Administrator\Desktop\Untitled1.ps1:5 char:10
+ $user.put <<<< ()[/code:1]

et bien sur la propriété du service n'est pas modifiée...

J'ai tenté en faisant un cast explicite du style
[code:1]$user = [adsi] \"LDAP://VPC-Galo/cn=svc-ww-d-SPInst,cn=users,dc=galo,dc=lan\"[/code:1]
mais la propriété passwordchangeable est en lecture seule...


Qqun peut-il m'aider ?

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 17 ans 7 mois #2689 par Arnaud Petitjean
Bonjour Gregory,

Les manipulations d'AD avec PowerShell v1 sont un peu bizarres parfois; cela va être grandement amélioré dans la v2.
En attendant, il faut essayer de travailler avec la méthode InvokeSet ou de \"traffiquer\" la propriété UserAccountCountrol.

Essaye déjà ceci :
[code:1]
$user = [adsi]\"LDAP://VPC-Galo/cn=svc-ww-d-SPInst,cn=users,dc=galo,dc=lan\"
$user.psbase.InvokeSet('passwordchangeable', $True)
$user.SetInfo()
[/code:1]

Pour vérifier si cela a fonctionné, tu peux utiliser la méthode InvokeGet, comme ceci :
[code:1]
$user = [adsi]\"LDAP://VPC-Galo/cn=svc-ww-d-SPInst,cn=users,dc=galo,dc=lan\"
$user.psbase.InvokeGet('passwordchangeable')
[/code:1]

Arnaud

MVP PowerShell et créateur de ce magnifique forum :-)
Auteur de 6 livres PowerShell aux éditions ENI
Fondateur de la société Start-Scripting
Besoin d'une formation PowerShell ?

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 17 ans 6 mois #2740 par gregory.ott
J'ai finalement opté pour une solution en .net.
Sur un objet existant dans l'AD $NouvelUser (type : DirectoryEntry)
[code:1]$self = [System.Security.Principal.SecurityIdentifier]'S-1-5-10'
$SelfDeny = new-object System.DirectoryServices.ActiveDirectoryAccessRule ($self,'ExtendedRight','Deny','ab721a53-1e2f-11d0-9819-00aa0040529b')
$NouvelUser.PSBase.get_ObjectSecurity().AddAccessRule($selfDeny)[/code:1]

Voila...


PS : je suis sur la V2 CTP2

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.049 secondes
Propulsé par Kunena