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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Création d'utilisateur Active Directory</title>
<Style>
Body {Background-Color: CornSilk}
</Style>
<script language="vbscript">
Option Explicit
Const cstOrganizationUnitName = "Clients"
Const cstDomainName = "@developpez.net"
'a ne pas changer
Const ADS_UF_DONT_EXPIRE_PASSWD = &h10000
Sub Window_onLoad
window.resizeTo 400,250
End Sub
Private Sub CreateADUser()
'Local Var
Dim ObjRoot,ObjDomain,ObjUser,strDisplayName
Dim strName,strFirstName
Set ObjRoot = GetObject("<a href="ldap://rootDSE" target="_blank">ldap://rootDSE</a>")
Set ObjDomain = GetObject("<a href="ldap://OU" target="_blank">ldap://OU</a> ="& cstOrganizationUnitName & "," & ObjRoot.Get("defaultNamingContext"))
strDisplayName = strName & " " & strFirstName & cstDomainName
If ((NomUtilisateur.value <> "") And (PrenomUtilisateur.value <> "")) Then
strName = PrenomUtilisateur.value
strFirstName = NomUtilisateur.value
Set ObjUser = ObjDomain.Create("User", "cn="& strName & " " & strFirstName)
ObjUser.Put "givenName",strFirstName
ObjUser.Put "sn",strName
ObjUser.Put "sAMAccountName", strName & "." & strFirstName
ObjUser.Put "Description", "Utilisateurs " & strName & " " & strFirstName
ObjUser.Put "displayName", strName & " " & strFirstName
ObjUser.Put "userPrincipalName", strDisplayName
ObjUser.SetInfo
ObjUser.SetPassword (strName & strFirstName)
ObjUser.AccountDisabled = False
ObjUser.put "PwdLastSet", 0
ObjUser.Put "userAccountControl", ADS_UF_DONT_EXPIRE_PASSWD
ObjUser.SetInfo
Else
MsgBox("Merci de vérifier le nom et le prénom")
End If
Set ObjRoot = Nothing
Set ObjDomain = Nothing
DataArea.innerhtml = "Success, Check Active Directory Users and Computers - Remember F5"
End Sub
</script>
<hta:application
applicationname="MyHTA"
border="dialog"
borderstyle="normal"
caption="My HTML Application"
contextmenu="no"
icon="myicon.ico"
maximizebutton="no"
minimizebutton="yes"
navigable="no"
scroll="no"
selection="no"
showintaskbar="no"
singleinstance="yes"
sysmenu="yes"
version="1.0"
windowstate="normal"
>
</head>
<body>
<p><h3 align = Left><font color='Blue'>Création d'Utilisateur Active Directory</font></h3>
<div></div>
<div>
Nom de l'utilisateur: <Input Type = "Text" Name = "NomUtilisateur">
</div>
<div>
Prénom de l'utilisateur: <Input Type = "Text" Name = "PrenomUtilisateur">
</div>
<br>
<div align="center">
<Input Type = "Button" Value = "Create User" align="center" Name = "Run_Button" onClick = "CreateADUser"><P>
</div>
<Span Id = "DataArea"></Span>
</body>
</html> |
Partager