⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 page701.vbs

📁 Apress - Managing Enterprise Systems With The Windows Script Host Source Code
💻 VBS
字号:
  Dim objConn, objRst, aMailBoxes, nPos, objMailbox, nF
  Set objConn = CreateObject("ADODB.Connection")
  objConn.Provider = "ADsDSOObject"
  objConn.Open "Active Directory Provider"
  
  'execute a query against the Exchange server Odin, listing all mailboxes
  'where the department is Accounting
  Set objRst = _
    objConn.Execute("SELECT ADsPath FROM " & _
        "'LDAP://Odin" & _
        "' WHERE objectClass='organizationalPerson' AND department='Accounting'")
   
   'loop through all mailboxes and output the display name
   Do While Not objRst.EOF
    'get the mailbox object from directory using the object path
    Set objMailbox = GetObject(objRst("ADsPath"))
    aMailBoxes = objMailbox.otherMailbox
    
    'check if aMailBoxes returns an array of values
    If VarType(aMailBoxes) = 8204 Then     
 'loop through each E-mail address in array
        For nF = 0 To UBound(aMailBoxes)
      'check if E-mail address contains Acme.com, if so
      ' replace with accounting.acme.com
         
    If StrComp(Right(aMailBoxes(nF), 9),"@acme.com",vbTextCompare) = 0 Then
            nPos = InStr(aMailBoxes(nF), "@acme.com")
            aMailBoxes(nF) = Left(aMailBoxes(nF), nPos-1) & "accounting.acme.com"
            objMailbox.Put "otherMailbox", aMailBoxes
            objMailbox.SetInfo
          End If
      Next
    End If
    
    objRst.MoveNext
   Loop
   objRst.Close
   objConn.Close 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -