2011年1月25日星期二
2009年4月29日星期三
Exchange2003 OWA开发(新建邮件)
最近一直在做OWA结构化地址薄的项目,碰到OWA根据选择的邮箱地址通过URL方式新建邮件的功能。
OWA支持以http://hvlab.local/Exchange/?Cmd=new&mailtoaddr=test01@hvlab.local新建邮件,但这种参数方式不支持抄送人和密送人的URL传递,通过修改OWA的js脚本可以实现这种功能,在OWA脚本目录下找到frm_ComposeNote.js脚本文件(如下图)

在脚本文件中加入如下代码:
function getQuery(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return "";
}
function getMailCc() {
var txttest = document.getElementById("MsgCc");
txttest.value = getQuery("mailcc");
}
function getMailBcc() {
var txttest = document.getElementById("MsgBcc");
txttest.value = getQuery("mailbcc");
}
现在可以通过URL方式传递抄送人和密送人了,需要注意每个参数的名称不能写错
http://hvlab.local/Exchange/?Cmd=new&mailtoaddr=test01@hvlab.local&mailcc=test02@hvlab.local&mailbcc=test03@hvlab.local
收件人:mailtoaddr
抄送人:mailcc
密送人:mailbcc
OWA支持以http://hvlab.local/Exchange/?Cmd=new&mailtoaddr=test01@hvlab.local新建邮件,但这种参数方式不支持抄送人和密送人的URL传递,通过修改OWA的js脚本可以实现这种功能,在OWA脚本目录下找到frm_ComposeNote.js脚本文件(如下图)

在脚本文件中加入如下代码:
function getQuery(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return "";
}
function getMailCc() {
var txttest = document.getElementById("MsgCc");
txttest.value = getQuery("mailcc");
}
function getMailBcc() {
var txttest = document.getElementById("MsgBcc");
txttest.value = getQuery("mailbcc");
}
现在可以通过URL方式传递抄送人和密送人了,需要注意每个参数的名称不能写错
http://hvlab.local/Exchange/?Cmd=new&mailtoaddr=test01@hvlab.local&mailcc=test02@hvlab.local&mailbcc=test03@hvlab.local
收件人:mailtoaddr
抄送人:mailcc
密送人:mailbcc
2009年3月11日星期三
查找域中用户并重置密码
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
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") = ADS_SCOPE_SUBTREE
'***
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set cnvt=CreateObject("ADs.ArrayConvert")
'*****
Set objTextFile = objFSO.OpenTextFile("D:\zn\cscript\20090310\reset_password.txt", ForReading)
Password="Password@1"
setAcount=0
'*****
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
'--------------Start--------------
'If trim(strNextLine)<>"" Then
' arrUserInfo=Split(strNextLine,",")
'End If
'********
objCommand.CommandText = _
"SELECT Name,ADsPath FROM 'LDAP://dc=test,dc=com' WHERE objectCategory='user' " & _
"AND sAMAccountName='" & strNextLine & "'"
'Wscript.Echo objCommand.CommandText
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
If objRecordSet.RecordCount>0 Then
ComDNPath= objRecordSet.Fields("ADsPath")
Wscript.Echo objRecordSet.Fields("Name")
'Set objUser = GetObject(ComDNPath)
'objUser.SetPassword Password
'objUser.SetInfo
setAcount=setAcount+1
End If
objRecordSet.MoveNext
Loop
'********
'--------------End----------------
Loop
Wscript.Echo "Update Account Users:" & setAcount
objTextFile.Close
set objTextFile = Nothing
Const ADS_SCOPE_SUBTREE = 2
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") = ADS_SCOPE_SUBTREE
'***
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set cnvt=CreateObject("ADs.ArrayConvert")
'*****
Set objTextFile = objFSO.OpenTextFile("D:\zn\cscript\20090310\reset_password.txt", ForReading)
Password="Password@1"
setAcount=0
'*****
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
'--------------Start--------------
'If trim(strNextLine)<>"" Then
' arrUserInfo=Split(strNextLine,",")
'End If
'********
objCommand.CommandText = _
"SELECT Name,ADsPath FROM 'LDAP://dc=test,dc=com' WHERE objectCategory='user' " & _
"AND sAMAccountName='" & strNextLine & "'"
'Wscript.Echo objCommand.CommandText
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
If objRecordSet.RecordCount>0 Then
ComDNPath= objRecordSet.Fields("ADsPath")
Wscript.Echo objRecordSet.Fields("Name")
'Set objUser = GetObject(ComDNPath)
'objUser.SetPassword Password
'objUser.SetInfo
setAcount=setAcount+1
End If
objRecordSet.MoveNext
Loop
'********
'--------------End----------------
Loop
Wscript.Echo "Update Account Users:" & setAcount
objTextFile.Close
set objTextFile = Nothing
2009年2月2日星期一
导出加入域的计算机信息脚本(计算机名、最后登录时间)
CONST ForWriting = 2
CONST ForAppending = 8
CONST CONST_ERROR = 0
CONST CONST_WSCRIPT = 1
CONST CONST_CSCRIPT = 2
CONST CONST_SHOW_USAGE = 3
CONST CONST_LIST = 4
Const ADS_SCOPE_SUBTREE = 2
Const ADS_UF_DONT_EXPIRE_PASSWD = 65536
Const ADS_UF_PASSWORD_EXPIRED = 8388608
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Const ONE_HUNDRED_NANOSECOND = .000000100
Const SECONDS_IN_DAY = 86400
Dim lastLogin
Set objShell = CreateObject("Wscript.Shell")
lngBiasKey = objShell.RegRead("HKLM\System\CurrentControlSet\Control\" _
& "TimeZoneInformation\ActiveTimeBias")
If (UCase(TypeName(lngBiasKey)) = "LONG") Then
lngBias = lngBiasKey
ElseIf (UCase(TypeName(lngBiasKey)) = "VARIANT()") Then
lngBias = 0
For k = 0 To UBound(lngBiasKey)
lngBias = lngBias + (lngBiasKey(k) * 256^k)
Next
End If
Set objShell = Nothing
'''''''''''''''''''''''''
Outputfile= strDCName1 & "计算机列表"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set fLog = fso.OpenTextFile(Outputfile & ".csv", ForWriting,TRUE)
fLog.WriteLine "机器名,最后登陆时间"
Set rootDSE = GetObject("LDAP://rootDSE")
BaseDN = rootDSE.Get("defaultNamingContext")
DC= replace(BaseDN,"DC=",",")
DC= replace(DC,",,",".")
DC=right(DC,len(DC)-1)
TARGET_OU= "Machines"
inputOU=inputbox("请输入所需查询计算机的OU,该OU必须位于Machines的下一层,不输入为查询所有计算机","输入信息")
if inputOU<>"" then
TARGET_OU= inputOU & ",OU=" & TARGET_OU
end if
inputdate=0
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand = CreateObject("ADODB.Command")
Set objCommand.ActiveConnection = objConnection
Set objCommand1 = CreateObject("ADODB.Command")
Set objCommand1.ActiveConnection = objConnection
'on error resume next
objCommand.CommandText = ";(&(objectclass=organizationalUnit));cn,ADsPath;subtree"
'msgbox ";(&(objectclass=organizationalUnit));cn,ADsPath;subtree"
Set objRecordSet = objCommand.Execute
if err.number<>0 then
msgbox "无法找到:" & TARGET_OU
end if
wscript.echo "Begin:"
If objRecordSet.RecordCount>0 Then
objRecordSet.MoveFirst
i = 0
Do Until objRecordSet.EOF
Set OU = GetObject(objRecordSet.Fields("ADsPath").Value)
OUdistinguishedName=OU.distinguishedName
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
strBase = ""
' Filter on all user objects.
strFilter = "(&(objectcategory=Computer)(objectClass=user))"
' Comma delimited list of attribute values to retrieve.
strAttributes = "distinguishedName,ADsPath,lastLogonTimeStamp"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
' Run the query.
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 10000
adoCommand.Properties("Timeout") = 60
adoCommand.Properties("Cache Results") = False
Set adoRecordset = adoCommand.Execute
' Enumerate resulting recordset.
Do Until adoRecordset.EOF
On Error Resume Next
adspath=adoRecordset.Fields("adspath")
ShowMSG adspath
Set objMailbox = GetObject(adspath) lastName=objMailbox.sn
computername=objMailbox.Name
company=objMailbox.company
department=objMailbox.department
Set objDate = adoRecordset.Fields("lastLogonTimeStamp").Value
If (Err.Number <> 0) Then
On Error GoTo 0
dtmDate = #1/1/1601#
Else
On Error GoTo 0
lngHigh = objDate.HighPart
lngLow = objDate.LowPart
If (lngLow < 0) Then
lngHigh = lngHigh + 1
End If
If (lngHigh = 0) And (lngLow = 0 ) Then
dtmDate = #1/1/1601#
Else
dtmDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _
+ lngLow)/600000000 - lngBias)/1440
End If
End If
lastLogin=dtmDate computername=replace(computername,"CN=","")
fLog.WriteLine computername & "," & lastLogin
adoRecordset.MoveNext
Loop
i=i+1
objRecordSet.MoveNext
Loop
End If
wscript.echo "Count:" & i
Sub ShowMSG(strSubMSG)
Wscript.Echo Time & vbTab & strSubMSG
end sub
CONST ForAppending = 8
CONST CONST_ERROR = 0
CONST CONST_WSCRIPT = 1
CONST CONST_CSCRIPT = 2
CONST CONST_SHOW_USAGE = 3
CONST CONST_LIST = 4
Const ADS_SCOPE_SUBTREE = 2
Const ADS_UF_DONT_EXPIRE_PASSWD = 65536
Const ADS_UF_PASSWORD_EXPIRED = 8388608
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Const ONE_HUNDRED_NANOSECOND = .000000100
Const SECONDS_IN_DAY = 86400
Dim lastLogin
Set objShell = CreateObject("Wscript.Shell")
lngBiasKey = objShell.RegRead("HKLM\System\CurrentControlSet\Control\" _
& "TimeZoneInformation\ActiveTimeBias")
If (UCase(TypeName(lngBiasKey)) = "LONG") Then
lngBias = lngBiasKey
ElseIf (UCase(TypeName(lngBiasKey)) = "VARIANT()") Then
lngBias = 0
For k = 0 To UBound(lngBiasKey)
lngBias = lngBias + (lngBiasKey(k) * 256^k)
Next
End If
Set objShell = Nothing
'''''''''''''''''''''''''
Outputfile= strDCName1 & "计算机列表"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set fLog = fso.OpenTextFile(Outputfile & ".csv", ForWriting,TRUE)
fLog.WriteLine "机器名,最后登陆时间"
Set rootDSE = GetObject("LDAP://rootDSE")
BaseDN = rootDSE.Get("defaultNamingContext")
DC= replace(BaseDN,"DC=",",")
DC= replace(DC,",,",".")
DC=right(DC,len(DC)-1)
TARGET_OU= "Machines"
inputOU=inputbox("请输入所需查询计算机的OU,该OU必须位于Machines的下一层,不输入为查询所有计算机","输入信息")
if inputOU<>"" then
TARGET_OU= inputOU & ",OU=" & TARGET_OU
end if
inputdate=0
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand = CreateObject("ADODB.Command")
Set objCommand.ActiveConnection = objConnection
Set objCommand1 = CreateObject("ADODB.Command")
Set objCommand1.ActiveConnection = objConnection
'on error resume next
objCommand.CommandText = "
'msgbox "
Set objRecordSet = objCommand.Execute
if err.number<>0 then
msgbox "无法找到:" & TARGET_OU
end if
wscript.echo "Begin:"
If objRecordSet.RecordCount>0 Then
objRecordSet.MoveFirst
i = 0
Do Until objRecordSet.EOF
Set OU = GetObject(objRecordSet.Fields("ADsPath").Value)
OUdistinguishedName=OU.distinguishedName
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
strBase = "
' Filter on all user objects.
strFilter = "(&(objectcategory=Computer)(objectClass=user))"
' Comma delimited list of attribute values to retrieve.
strAttributes = "distinguishedName,ADsPath,lastLogonTimeStamp"
' Construct the LDAP syntax query.
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
' Run the query.
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 10000
adoCommand.Properties("Timeout") = 60
adoCommand.Properties("Cache Results") = False
Set adoRecordset = adoCommand.Execute
' Enumerate resulting recordset.
Do Until adoRecordset.EOF
On Error Resume Next
adspath=adoRecordset.Fields("adspath")
ShowMSG adspath
Set objMailbox = GetObject(adspath) lastName=objMailbox.sn
computername=objMailbox.Name
company=objMailbox.company
department=objMailbox.department
Set objDate = adoRecordset.Fields("lastLogonTimeStamp").Value
If (Err.Number <> 0) Then
On Error GoTo 0
dtmDate = #1/1/1601#
Else
On Error GoTo 0
lngHigh = objDate.HighPart
lngLow = objDate.LowPart
If (lngLow < 0) Then
lngHigh = lngHigh + 1
End If
If (lngHigh = 0) And (lngLow = 0 ) Then
dtmDate = #1/1/1601#
Else
dtmDate = #1/1/1601# + (((lngHigh * (2 ^ 32)) _
+ lngLow)/600000000 - lngBias)/1440
End If
End If
lastLogin=dtmDate computername=replace(computername,"CN=","")
fLog.WriteLine computername & "," & lastLogin
adoRecordset.MoveNext
Loop
i=i+1
objRecordSet.MoveNext
Loop
End If
wscript.echo "Count:" & i
Sub ShowMSG(strSubMSG)
Wscript.Echo Time & vbTab & strSubMSG
end sub
2009年1月22日星期四
SQL SERVER 默认数据库实例的作用
master 数据库
master 数据库记录 SQL Server 系统的所有系统级别信息。它记录所有的登录帐户和系统配置设置,所有其它的数据库,其中包括数据库文件的位置。master 数据库记录 SQL Server 的初始化信息,它始终有一个可用的最新 master 数据库备份。
tempdb 数据库
tempdb 数据库保存所有的临时表和临时存储过程。它还满足任何其它的临时存储要求,例如存储 SQL Server 生成的工作表。tempdb 数据库是全局资源,所有连接到系统的用户的临时表和存储过程都存储在该数据库中。tempdb 数据库在 SQL Server 每次启动时都重新创建,因此该数据库在系统启动时总是干净的。临时表和存储过程在连接断开时自动除去,而且当系统关闭后将没有任何连接处于活动状态,因此 tempdb 数据库中没有任何内容会从 SQL Server 的一个会话保存到另一个会话。
默认情况下,在 SQL Server 在运行时 tempdb 数据库会根据需要自动增长。不过,与其它数据库不同,每次启动数据库引擎时,它会重置为其初始大小。如果为 tempdb 数据库定义的大小较小,则每次重新启动 SQL Server时,将tempdb 数据库的大小自动增加到支持工作负荷所需的大小这一工作可能会成为系统处理负荷的一部分。为避免这种开销,可以使用 ALTER DATABASE 增加 tempdb 数据库的大小。
model 数据库
model 数据库用作在系统上创建的所有数据库的模板。当发出 CREATE DATABASE 语句时,新数据库的第一部分通过复制 model 数据库中的内容创建,剩余部分由空页填充。由于 SQL Server 每次启动时都要创建 tempdb 数据库,model 数据库必须一直存在于 SQL Server 系统中。
msdb 数据库
msdb 数据库供 SQL Server 代理程序调度警报和作业以及记录操作员时使用。
Northwind 示例数据库
Northwind Traders 示例数据库包含一个名为 Northwind Traders 的虚构公司的销售数据,该公司从事世界各地的特产食品进出口贸易
pubs 示例数据库
pubs 示例数据库以一个图书出版公司为模型,用于演示 SQL Server 数据库中可用的许多选项。该数据库及其中的表经常在文档内容所介绍的示例中使用。
master 数据库记录 SQL Server 系统的所有系统级别信息。它记录所有的登录帐户和系统配置设置,所有其它的数据库,其中包括数据库文件的位置。master 数据库记录 SQL Server 的初始化信息,它始终有一个可用的最新 master 数据库备份。
tempdb 数据库
tempdb 数据库保存所有的临时表和临时存储过程。它还满足任何其它的临时存储要求,例如存储 SQL Server 生成的工作表。tempdb 数据库是全局资源,所有连接到系统的用户的临时表和存储过程都存储在该数据库中。tempdb 数据库在 SQL Server 每次启动时都重新创建,因此该数据库在系统启动时总是干净的。临时表和存储过程在连接断开时自动除去,而且当系统关闭后将没有任何连接处于活动状态,因此 tempdb 数据库中没有任何内容会从 SQL Server 的一个会话保存到另一个会话。
默认情况下,在 SQL Server 在运行时 tempdb 数据库会根据需要自动增长。不过,与其它数据库不同,每次启动数据库引擎时,它会重置为其初始大小。如果为 tempdb 数据库定义的大小较小,则每次重新启动 SQL Server时,将tempdb 数据库的大小自动增加到支持工作负荷所需的大小这一工作可能会成为系统处理负荷的一部分。为避免这种开销,可以使用 ALTER DATABASE 增加 tempdb 数据库的大小。
model 数据库
model 数据库用作在系统上创建的所有数据库的模板。当发出 CREATE DATABASE 语句时,新数据库的第一部分通过复制 model 数据库中的内容创建,剩余部分由空页填充。由于 SQL Server 每次启动时都要创建 tempdb 数据库,model 数据库必须一直存在于 SQL Server 系统中。
msdb 数据库
msdb 数据库供 SQL Server 代理程序调度警报和作业以及记录操作员时使用。
Northwind 示例数据库
Northwind Traders 示例数据库包含一个名为 Northwind Traders 的虚构公司的销售数据,该公司从事世界各地的特产食品进出口贸易
pubs 示例数据库
pubs 示例数据库以一个图书出版公司为模型,用于演示 SQL Server 数据库中可用的许多选项。该数据库及其中的表经常在文档内容所介绍的示例中使用。
订阅:
博文 (Atom)