|
楼主 |
发表于 2008-4-23 09:22:44
|
显示全部楼层
VB程序很简单,只需一个定时器控件,加上以下代码,就可以在每天0时检查到期用户,并踢下线。
Private Sub Timer1_Timer()
If Val(Time) = 0 Then
Dim Conn As New ADODB.Connection
Dim Rst As New ADODB.Recordset
Conn.Open "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=radius;User ID=sa;password=sa"
Rst.Open "SELECT username FROM username WHERE online='yes' and DATEDIFF(" + Chr(34) + "d" + Chr(34) + ",disable_time,GETDATE())>=0", Conn, adOpenStatic, adLockOptimistic
While Not Rst.EOF
Dim rec As String
Dim ip As String
rec = Rst.Fields("username")
ip=Rst.Fields("nas_ip")
Shell "cmd /c echo User-Name=" + rec + " | radclient.exe -d ../etc/raddb -x "+ip+":1700 disconnect vpn", vbHide
Rst.MoveNext
Wend
End If
End Sub
以上代码中所用的sql server数据库名是radius,管理员和密码都是sa,用于记录拨号用户资料和拨号状态的表是username,里面最少有这几个字段:username(用户名)、online(是否在线)、disable_time(到期时间)
[ 本帖最后由 bfrader 于 2008-4-23 09:26 编辑 ] |
|