글 작성자: 써니루루

출처 : Read RTC properties from active directory users
http://www.haverhoek.nl/index.php?/archives/22-Read-RTC-properties-from-active-directory-users.html


이 스크립트는 AD의 사용자중에 RTC 활성화된 사용자의 RTC 정보를 읽을 수 있는 스크립트입니다.
This script reads all RTC properties from all RTC enabled users from Active Directory.

파일을 적당한 이름의 *.vbs 로 저장한 후 실행해 보시면 됩니다.

사용자가 많을 경우 Alert 창이 여러번 뜨기 때문에 출력방식을 바꾸거나 파일로 저장하도록 하는 방법도 좋을듯 하네요.

On Error Resume Next

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

' Search for users that are RTC enabled
objCommand.CommandText = "Select samAccountName,msRTCSIP-PrimaryUserAddress,msRTCSIP-FederationEnabled" & _
",msRTCSIP-ArchivingEnabled,msRTCSIP-InternetAccessEnabled,msRTCSIP-Line,msRTCSIP-LineServer" & _
",msRTCSIP-UserEnabled,msRTCSIP-UserExtension,msRTCSIP-UserPolicy,telephoneNumber,mail" & _
",msRTCSIP-OptionFlags,msRTCSIP-OriginatorSid,msRTCSIP-PrimaryHomeServer,msRTCSIP-TargetHomeServer " & _
"from 'LDAP://dc=domain,dc=local' " & _
"where objectClass='user' and msRTCSIP-UserEnabled=TRUE"

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = 2
objCommand.Properties("Cache Results") = False
Set objRecordSet = objCommand.Execute

Do Until objRecordSet.EOF
strAccountName = objRecordset.Fields("samAccountName").Value
wscript.echo "strAccountName = " & strAccountName

strURI = objRecordset.Fields("msRTCSIP-PrimaryUserAddress").Value
wscript.echo "strURI = " & strURI

bFederationEnabled = objRecordset.Fields("msRTCSIP-FederationEnabled").Value
wscript.echo "bFederationEnabled = " & CStr(bFederationEnabled)

strArchivingEnabled = objRecordset.Fields("msRTCSIP-ArchivingEnabled").Value
wscript.echo "strArchivingEnabled = " & strArchivingEnabled

bInternetAccessEnabled = objRecordset.Fields("msRTCSIP-InternetAccessEnabled").Value
WScript.Echo "bInternetAccessEnabled = " & CStr(bInternetAccessEnabled)

strLine = objRecordset.Fields("msRTCSIP-Line").Value
WScript.Echo "strLine = " & strLine

strLineServer = objRecordset.Fields("msRTCSIP-LineServer").Value
WScript.Echo "strLineServer = " & strLineServer

intOptionFlags = objRecordset.Fields("msRTCSIP-OptionFlags").Value
WScript.Echo "intOptionFlags = " & intOptionFlags

sidOriginatorSid = objRecordset.Fields("msRTCSIP-OriginatorSid").value
WScript.Echo "sidOriginatorSid = " & sidOriginatorSid

strPrimaryHomeServer = objRecordset.Fields("msRTCSIP-PrimaryHomeServer").value
WScript.Echo "strPrimaryHomeServer = " & strPrimaryHomeServer

strTargetHomeServer = objRecordset.Fields("msRTCSIP-TargetHomeServer").value
WScript.Echo "strTargetHomeServer = " & strTargetHomeServer

bUserEnabled = objRecordset.Fields("msRTCSIP-UserEnabled").value
WScript.Echo "bUserEnabled = " & CStr(bUserEnabled)

strUserExtension = objRecordset.Fields("msRTCSIP-UserExtension").value
WScript.Echo "strUserExtension = " & strUserExtension

binUserPolicy = objRecordset.Fields("msRTCSIP-UserPolicy").value
WScript.Echo "binUserPolicy = " & binUserPolicy

strTelephoneNumber = objRecordset.Fields("telephoneNumber").value
WScript.Echo "strTelephoneNumber = " & strTelephoneNumber

strMail = objRecordset.Fields("mail").value
WScript.Echo "strMail = " & strMail

WScript.Echo "================================================="

objRecordSet.MoveNext
Loop


objRecordSet.Close
Set objRecordSet = Nothing
Set objCommand = Nothing
objConnection.Close
Set objConnection = Nothing