Bonjour,
Je dois réaliser un webservice qui pourra permettre de changer les mots de passe utilisateurs de windows.
J'ai essayé avec les fonctions LDAP, sans succés.
J'ai trouvé sur internet un petit script qui permet de modifier les mot de passe, il fonctionne très bien, je l'ai adapté pour qu'il prenne en compte 3 paramètres (Nom, Ancien mdp et Nouveau mdp). Lorsque que je suis en mode debug, le script est bien lancer par le webservice via la commande LanceAppli.
Cependant, lorsque le webservice est déployé impossible de lancer le script, comme LanceAppli est en mode Bloquant, la page de test du webservice tourne en boucle.(Marche pas en mode nonBloquant non plus, de toute façon)
Il est a noté que le script est un vbs, que je le lance grâce a wscript.exe, est qu'il apparaît bien dans mes processus actifs sans pour autant fonctionner.
Voici le code du webservice:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 sTexte est une chaîne sTexte = "scriptmdp.vbs" + " " + NomUser + " " +AncienMdP+ " " +NouveauMdP exec est une chaîne = "C:\WINDOWS\System32\WScript.exe" chaineScript est une chaîne = exec + " " + sTexte SI LanceAppli(chaineScript,exeActif,exeBloquant) ALORS RENVOYER "Ok" SINON RENVOYER ErrorInfo(errComplet) FIN
Voici le code du script (au cas où):
Merci d'avance !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 option explicit const strLDAPRoot = "LDAP://MonDomaine" const intNormalOperation = 0 const intUserNotFound = 1 const intCouldNotChangePassword = 2 dim strUserName dim strUserOldPassword dim strUserNewPassword dim strUserDN strUserName = Wscript.Arguments(0) strUserOldPassword = Wscript.Arguments(1) strUserNewPassword = Wscript.Arguments(2) strUserDN = GetUserDistinguishedname(strLDAPRoot, strUserName) if strUserDN <> "" then ChangeUserPassword strUserDN, strUserOldPassword, strUserNewPassword CheckForError intCouldNotChangePassword wscript.quit intNormalOperation else wscript.quit end if Function GetUserDistinguishedName(strLDAPRoot, strSamAccountName) dim objConnection dim objCommand dim objRecordset Set objConnection = CreateObject("ADODB.Connection") objConnection.Open "Provider=ADsDSOObject;" Set objCommand = CreateObject("ADODB.Command") objCommand.ActiveConnection = objConnection objCommand.CommandText = "SELECT distinguishedName FROM '" & strLDAPRoot & "' WHERE objectCategory='user' AND sAMAccountName='" & strSamAccountName & "'" Set objRecordSet = objCommand.Execute if Not objRecordset.EOF then GetUserDistinguishedName = objRecordset.Fields("distinguishedname") end if objConnection.Close End Function Function GetUserLastPasswordChange(strUserDN) dim objUser Set objUser = GetObject("LDAP://" & strUserDN) GetUserLastPasswordChange = objUser.PasswordLastChanged End Function Function ChangeUserPassword(strUserDN, strOldPassword, strNewPassword) dim objUser MsgBox "je suis dans la fonction : ChangeUserPassword" Set objUser = GetObject("LDAP://" & strUserDN) objUser.ChangePassword strOldPassword, strNewPassword End Function Sub CheckForError(intErrorCondition) if err.number <> 0 then wscript.quit intErrorCondition end if end sub
Partager