Bonjour à tous,
Je désire me faire une interface web afin d'effectuer à distance certaines tâches d'administration réseau. Là je veux faire une page pour délocker un usager. Je me crée une fonction en Vbs (qui fonctionne très bien lorsque je la save dans un fichier vbs) mais lorsque je la mets dans une page ASP, ça ne marche pas. Je ne sais vraiment pas ce que je fais de pas correct. Voici le code:
Code :
<%
On Error Resume Next
Function UnlockUser(sUser)
Dim oUser
sUser = "test"
Set oUser = GetObject("WinNT://domain.com/" & sUser & ",user")
'User Found?
If Err <> 0 Then
'no!
MsgBox = "User Not Found!"
Else
If oUser.IsAccountLocked = False Then
sMsg = "The Account Unlock Failed. Check that the account is, in fact, locked-out."
Else
oUser.IsAccountLocked = False
oUser.SetInfo
sMsg = "User Unlock Successful"
End If
End If
UnlockUser = sMsg
End Function
%>
<html>
<body>
<p align=center style='text-align:center'><b>Unlock User Account</b><i><br>
This page will work only for domain administrators or account operators.</i></p>
<form action=UserUnlock.asp method=POST
enctype="application/x-www-form-urlencoded">
<p align=center style='text-align:center'>User ID:<br>
<INPUT TYPE="text" SIZE="20" NAME="UserID"><o:p></o:p></p>
<p align=center style='text-align:center'><INPUT TYPE="submit" ACTION="UserUnlock.asp" METHOD="POST" NAME="Submit"
ACTION=UserUnlock.asp METHOD=POST ACTION=UserUnlock.asp METHOD=POST></p>
<div class=MsoNormal align=center style='text-align:center'>
<hr size=2 width="100%" noshade color=black align=center>
</form>
<%
If Request("Submit") <> "" Then
%>
<p align=center style='margin-bottom:12.0pt;text-align:center'><b>Result for</b>
<u> <% Response.Write Request("UserID") %><br></u>
<b><% Response.Write UnlockUser(Request("UserID")) %></b></p>
<% End If %>
<p class=MsoNormal align=center style='text-align:center'><span
style='font-size:10.0pt;font-family:Arial'><a
href="http://webserver/Default.htm">Main Menu</a><o:p></o:p></span></p>
<p class=MsoNormal align=center style='text-align:center'><span
style='font-size:10.0pt;font-family:Arial'><a
href="http://webserver/Active_Directory.htm">Active Directory Menu</a><o:p></o:p></span></p>
</body>
</html>
_________________
Some persons are like slinky
They don't really have a purpose but they bring a smile on our face when we push them down the stairs.
Spécialiste en infrastructure / virtualisation. Pour plus de détails:
http://www.fbsc.ca