作者 主題: [分享]透過vb script 在linux sendmail主機上建立帳號  (閱讀 2639 次)

0 會員 與 1 訪客 正在閱讀本文。

小徒兒

  • 鑽研的研究生
  • *****
  • 文章數: 622
    • 檢視個人資料
1. download putty.exe   on the web server C:\

C:\putty.exe

引用
來源:鳥哥的私房菜  http://linux.vbird.org/linux_server/0310telnetssh.php#ssh_client_putty

那麼如果想要中文支援的話,目前 putty 已經支援中文啦!您可以輸入中文喔!不過需要修改一下字元集,選擇左邊畫面的『window』項目, 並選擇『Appearance』設定內容,設定:
在出現的上面框框中,選擇右邊第二個項目內的『Change』去修改字元集顯示:
將(1)字型設定為細明體 (2)字集設定為『Big5』,如此一來,您的 putty 就支援中文的輸入囉! ^_^


2. in the Web Server command line, enter
代碼: [選擇]

cd C:\
'漿螢幕上的文字放置genfile.bat
copy con genfile.bat
echo . test.sh %1 %2 %3> C:\test.txt
echo . testalias.sh %1 %4 >> C:\test.txt
^Z


2.1 in the senmail server add one user,give the useradd authority

#useradd easyflow
#visudo
(add the line to give the authority)
easyflow ALL=NOPASSWD:/usr/sbin/useradd

2.2 on the home directory of user easyflow, write the shell script for adding account

(login as easyflow)
#cd ~easyflow
#vi test.sh

'只需echo一次喔
代碼: [選擇]
sudo /usr/sbin/useradd $1 -c $3
echo > ~easyflow/xxx.log
echo $2 > ~easyflow/xxx.log
sudo /usr/bin/passwd --stdin $1 <xxx.log


3. on your computer to develop the active X .dll file

project name: testdll1
class name: testdllclass1


代碼: [選擇]
Public Function ReturnRs(DBname As String, SPname As String) As ADODB.Recordset
'Returns an ADODB recordset
On Error GoTo ehGetRecordset
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strConnect As String
Dim ADF As New RDSServer.DataFactory

strDB = DBname
strSQL = SPname
strConnect = "Provider=SQLOLEDB;Server=172.16.200.85;uid=sa;pwd=; Database=" & strDB & ";"
cn.Open strConnect

rs.CursorLocation = adUseClient
rs.Open strSQL, cn, adOpenForwardOnly, adLockOptimistic, adCmdText


Set ReturnRs = rs

Exit Function
ehGetRecordset:
Err.Raise Err.Number, Err.Source, Err.Description

End Function

Public Function AddEmail(EmailName As String, Password As String, DepRealName As String)

Public Function AddEmail(EmailName As String, Password As String, DepRealName As String, MailAlias As String)

Dim RetVal
RetVal = Shell("C:\genfile.bat " + EmailName + "," + Password + "," + DepRealName + "," + MailAlias, 0)
' RetVal = Shell("C:\genfile1.bat " + EmailName, 0)

RetVal = Shell("C:\putty.EXE -ssh -l easyflow -m c:\test.txt -pw 記得改我成正確的密碼 mail.nettrade.com.tw", 0)

End Function



4. make it and copy the testdll1.dll to the web server
locate C:\windows\system32\testdll1.dll

5. regsvr32 testdll1.dll

if you want to reinstall

regsvr32 testdll1.dll /uninstll
regsvr32 testdll1.dll

6. in the 元件管理
COM +應用程式

新增應用程式/建立空的應用程式/
named: testdll1
checked: 伺服應用程式
使用下列使用者,可以有寫入webserver 檔案系統及執行shell的

[keyin the domain\username]
[passwordofuser]
[passwordofuser]

7. on the testdll1 伺服應用程式 /元件/右鍵新增元件
選擇 匯入已登入的元件 testdll1.testdllclass1

8.選擇元件/內容/ 安全設定 強制元件存取 的勾勾拿掉

9. regedit
change the
代碼: [選擇]
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\
    Parameters\ADCLaunch\yourprogid.yourclassname (project and class name of your Business Object)

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\
    Parameters\ADCLaunch\testdll1.testdllclass1


10. add the calling code on your vbscript code



注意 &""
代碼: [選擇]
'---------------------------------------------------------------
'vb script 寫在當某的輸入欄位失去focus時
'---------------------------------------------------------------
sub employid_onblur()
Dim rds,rs,df,df2,ServerStr
dim strSQL,StrRs
dim ME001,ME002

set rds = CreateObject("RDS.Dataspace")
Set df = rds.CreateObject("testdll1.testdllclass1","<%=Session("http")%><%=Request.ServerVariables("SERVER_NAME")%>")

set rs = df.ReturnRs("EF2KWeb","sp_GetSTD005Data '" & document.all("employid").value & "'")


df.AddEmail document.all("efsty006").value,Replace(trim(document.all("efsty009").value), "$", "\$"),trim(document.all("efsty004").value)+trim(document.all("efsty001").value),rs("MailAlias")&""



'---------------------------------------------------------------
' 建立object  並呼叫其方法 add mail
' 建立帳號meow
' 注意 不能有括號 df.AddEmail("kk,"test","tst")
' 將$跳脫
'---------------------------------------------------------------

   df.AddEmail document.all("efsty006").value,Replace(trim(document.all("efsty009").value), "$", "\$"),trim(document.all("efsty004").value)+trim(document.all("efsty001").value)
    
'---------------------------------------------------------------
' 將透過object捞到的資料 呈?#123;於相關的連動欄位
'
'---------------------------------------------------------------


if rs.RecordCount = 0 then

        'document.all("img01").alt = "?#91;班申請人尚未簽出,若簽出將告知簽出時間"    
else

document.all("efsty001").value=rs("efsty001")
document.all("efsty002").value=rs("efsty002")
document.all("efsty003").value=rs("efsty003")
document.all("efsty004").value=rs("efsty004")
document.all("efsty005").value=rs("efsty005")


end if                        

end sub

11. run the putty.exe to connect to the sendmail server manually for one time to generate the key

12. validate the email account could not exceed 12 characters[/quote]
« 上次編輯: 2011-03-28 10:25 由 小徒兒 »