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
|
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = 2
Set WshNet = CreateObject("WScript.Network")
User = WshNet.Username
strUser = User
objCommand.CommandText = "SELECT Name, ADsPath FROM 'LDAP://dc=mjs,dc=local' where name='" & strUser & "*' and objectCategory='user'"
Set objRecordSet = objCommand.Execute
If objRecordSet.RecordCount > 0 Then
' on inscrit le cn dans une variable, et voilà
usrCN = objRecordSet.Fields("ADsPath").Value
Set objUser = GetObject (usrCN)
End If
dim dtmAccountExpiration
dtmAccountExpiration = objUser.AccountExpirationDate
If dtmAccountExpiration <> "01/01/1601 01:00:00" Then
A = dtmAccountExpiration - date ' A est la variable qui fait la difference entre les deux date (elle est inferieur ou superieur a 30)
If A < 31 Then
MsgBox "Votre compte expire le : " & objUser.AccountExpirationDate, vbExclamation, "Avertissement"
End If
End If |