zoukankan      html  css  js  c++  java
  • [JWF]使用脚本访问ActiveDirectory(二)GetObject()

    strContainer = "OU=系统维护室,OU=网管中心"
    strName = "徐中"

    On Error Resume Next

    '***********************************************
    '*          Connect to an object                 *
    '***********************************************
    Set objRootDSE = GetObject("LDAP://rootDSE")
    ' objRootDSE.Get("defaultNamingContext")  return value "DC=nmc,DC=ln,DC=cmcc"
    If strContainer = "" Then
      Set objItem = GetObject("LDAP://" & _
        objRootDSE.Get("defaultNamingContext"))
    Else
      Set objItem = GetObject("LDAP://cn=" & strName & "," & strContainer & "," & _
        objRootDSE.Get("defaultNamingContext"))
    End If
    '***********************************************
    '*         End connect to an object           *
    '***********************************************

    WScript.Echo VbCrLf & "** General Properties Page**"
    WScript.Echo "** (Single-Valued Attributes) **"
    strname = objItem.Get("name")
    WScript.Echo "name: " & strname
    strgivenName = objItem.Get("givenName")
    WScript.Echo "givenName: " & strgivenName
    strinitials = objItem.Get("initials")
    WScript.Echo "initials: " & strinitials
    strsn = objItem.Get("sn")
    WScript.Echo "sn: " & strsn
    strdisplayName = objItem.Get("displayName")
    WScript.Echo "displayName: " & strdisplayName
    strdescription = objItem.Get("description")
    WScript.Echo "description: " & strdescription
    strphysicalDeliveryOfficeName = objItem.Get("physicalDeliveryOfficeName")
    WScript.Echo "physicalDeliveryOfficeName: " & strphysicalDeliveryOfficeName
    strtelephoneNumber = objItem.Get("telephoneNumber")
    WScript.Echo "telephoneNumber: " & strtelephoneNumber
    strmail = objItem.Get("mail")
    WScript.Echo "mail: " & strmail
    strwWWHomePage = objItem.Get("wWWHomePage")
    WScript.Echo "wWWHomePage: " & strwWWHomePage

    WScript.Echo VbCrLf & "** General Properties Page**"
    WScript.Echo "** (MultiValued Attributes) **"
    strotherTelephone = objItem.GetEx("otherTelephone")
    WScript.Echo "otherTelephone:"
    For Each Item in strotherTelephone
     WScript.Echo vbTab & Item
    Next
    strurl = objItem.GetEx("url")
    WScript.Echo "url:"
    For Each Item in strurl
     WScript.Echo vbTab & Item
    Next

    WScript.Echo VbCrLf & "** Address Properties Page**"
    WScript.Echo "** (Single-Valued Attributes) **"
    strstreetAddress = objItem.Get("streetAddress")
    WScript.Echo "streetAddress: " & strstreetAddress
    strl = objItem.Get("l")
    WScript.Echo "l: " & strl
    strst = objItem.Get("st")
    WScript.Echo "st: " & strst
    strpostalCode = objItem.Get("postalCode")
    WScript.Echo "postalCode: " & strpostalCode
    strc = objItem.Get("c")
    WScript.Echo "c: " & strc

    WScript.Echo VbCrLf & "** Address Properties Page**"
    WScript.Echo "** (MultiValued Attributes) **"
    strpostOfficeBox = objItem.GetEx("postOfficeBox")
    WScript.Echo "postOfficeBox:"
    For Each Item in strpostOfficeBox
     WScript.Echo vbTab & Item
    Next

    WScript.Echo VbCrLf & "** Account Properties Page**"
    WScript.Echo "** (Single-Valued Attributes) **"
    struserPrincipalName = objItem.Get("userPrincipalName")
    WScript.Echo "userPrincipalName: " & struserPrincipalName
    strdc = objItem.Get("dc")
    WScript.Echo "dc: " & strdc
    strsAMAccountName = objItem.Get("sAMAccountName")
    WScript.Echo "sAMAccountName: " & strsAMAccountName
    struserWorkstations = objItem.Get("userWorkstations")
    WScript.Echo "userWorkstations: " & struserWorkstations

    WScript.Echo VbCrLf & "** Account Properties Page**"
    WScript.Echo "** (The userAccountControl attribute) **"
    Set objHash = CreateObject("Scripting.Dictionary")
    objHash.Add "ADS_UF_SMARTCARD_REQUIRED", &h40000
    objHash.Add "ADS_UF_TRUSTED_FOR_DELEGATION", &h80000
    objHash.Add "ADS_UF_NOT_DELEGATED", &h100000
    objHash.Add "ADS_UF_USE_DES_KEY_ONLY", &h200000
    objHash.Add "ADS_UF_DONT_REQUIRE_PREAUTH", &h400000
    intuserAccountControl = objItem.Get("userAccountControl")
    For Each Key in objHash.Keys
      If objHash(Key) And intuserAccountControl Then
        WScript.Echo Key & " is enabled."
      Else
        WScript.Echo Key & " is disabled."
      End If
    Next
    If objItem.IsAccountLocked = True Then
      WScript.Echo "ADS_UF_LOCKOUT is enabled"
    Else
      WScript.Echo "ADS_UF_LOCKOUT is disabled"
    End If

    If err.Number = -2147467259 OR _
      objItem.AccountExpirationDate = "1/1/1970" Then
      WScript.Echo "Account doesn't expire."
    Else
      WScript.Echo "Account expires on: " & objItem.AccountExpirationDate
    End If

    WScript.Echo VbCrLf & "** Profile Properties Page**"
    WScript.Echo "** (Single-Valued Attributes) **"
    strprofilePath = objItem.Get("profilePath")
    WScript.Echo "profilePath: " & strprofilePath
    strscriptPath = objItem.Get("scriptPath")
    WScript.Echo "scriptPath: " & strscriptPath
    strhomeDirectory = objItem.Get("homeDirectory")
    WScript.Echo "homeDirectory: " & strhomeDirectory
    strhomeDrive = objItem.Get("homeDrive")
    WScript.Echo "homeDrive: " & strhomeDrive

    WScript.Echo VbCrLf & "** Telephone Properties Page**"
    WScript.Echo "** (Single-Valued Attributes) **"
    strhomePhone = objItem.Get("homePhone")
    WScript.Echo "homePhone: " & strhomePhone
    strpager = objItem.Get("pager")
    WScript.Echo "pager: " & strpager
    strmobile = objItem.Get("mobile")
    WScript.Echo "mobile: " & strmobile
    strfacsimileTelephoneNumber = objItem.Get("facsimileTelephoneNumber")
    WScript.Echo "facsimileTelephoneNumber: " & strfacsimileTelephoneNumber
    stripPhone = objItem.Get("ipPhone")
    WScript.Echo "ipPhone: " & stripPhone
    strinfo = objItem.Get("info")
    WScript.Echo "info: " & strinfo

    WScript.Echo VbCrLf & "** Telephone Properties Page**"
    WScript.Echo "** (MultiValued Attributes) **"
    strotherHomePhone = objItem.GetEx("otherHomePhone")
    WScript.Echo "otherHomePhone:"
    For Each Item in strotherHomePhone
     WScript.Echo vbTab & Item
    Next
    strotherPager = objItem.GetEx("otherPager")
    WScript.Echo "otherPager:"
    For Each Item in strotherPager
     WScript.Echo vbTab & Item
    Next
    strotherMobile = objItem.GetEx("otherMobile")
    WScript.Echo "otherMobile:"
    For Each Item in strotherMobile
     WScript.Echo vbTab & Item
    Next
    strotherFacsimileTelephoneNumber = objItem.GetEx("otherFacsimileTelephoneNumber")
    WScript.Echo "otherFacsimileTelephoneNumber:"
    For Each Item in strotherFacsimileTelephoneNumber
     WScript.Echo vbTab & Item
    Next
    strotherIpPhone = objItem.GetEx("otherIpPhone")
    WScript.Echo "otherIpPhone:"
    For Each Item in strotherIpPhone
     WScript.Echo vbTab & Item
    Next

    WScript.Echo VbCrLf & "** Organization Properties Page**"
    WScript.Echo "** (Single-Valued Attributes) **"
    strtitle = objItem.Get("title")
    WScript.Echo "title: " & strtitle
    strdepartment = objItem.Get("department")
    WScript.Echo "department: " & strdepartment
    strcompany = objItem.Get("company")
    WScript.Echo "company: " & strcompany
    strmanager = objItem.Get("manager")
    WScript.Echo "manager: " & strmanager

    WScript.Echo VbCrLf & "** Organization Properties Page**"
    WScript.Echo "** (MultiValued Attributes) **"
    strdirectReports = objItem.GetEx("directReports")
    WScript.Echo "directReports:"
    For Each Item in strdirectReports
     WScript.Echo vbTab & Item
    Next

    WScript.Echo VbCrLf & "** Environment Properties Page**"
    WScript.Echo "** (The ADSI Extension for Terminal Services interface) **"
    WScript.Echo "TerminalServicesInitialProgram: " & _
      objItem.TerminalServicesInitialProgram
    WScript.Echo "TerminalServicesWorkDirectory: " & _
      objItem.TerminalServicesWorkDirectory
    WScript.Echo "ConnectClientDrivesAtLogon: " & _
      objItem.ConnectClientDrivesAtLogon
    WScript.Echo "ConnectClientPrintersAtLogon: " & _
      objItem.ConnectClientPrintersAtLogon
    WScript.Echo "DefaultToMainPrinter: " & _
      objItem.DefaultToMainPrinter

    WScript.Echo VbCrLf & "** Sessions Properties Page**"
    WScript.Echo "** (The ADSI Extension for Terminal Services interface) **"
    WScript.Echo "MaxDisconnectionTime: " & _
      objItem.MaxDisconnectionTime
    WScript.Echo "MaxConnectionTime: " & _
      objItem.MaxConnectionTime
    WScript.Echo "MaxIdleTime: " & _
      objItem.MaxIdleTime
    WScript.Echo "BrokenConnectionAction: " & _
      objItem.BrokenConnectionAction
    WScript.Echo "ReconnectionAction: " & _
      objItem.ReconnectionAction

    WScript.Echo VbCrLf & "** Remote Control Properties Page**"
    WScript.Echo "** (The ADSI Extension for Terminal Services interface) **"
    WScript.Echo "EnableRemoteControl: " & _
      objItem.EnableRemoteControl

    Select Case objItem.EnableRemoteControl
      Case 0
        WScript.Echo "Remote Control disabled"
      Case 1
        WScript.Echo "Remote Control enabled"
        WScript.Echo "User permission required"
        WScript.Echo "Interact with the session"
      Case 2
        WScript.Echo "Remote Control enabled"
        WScript.Echo "User permission not required"
        WScript.Echo "Interact with the session"
      Case 3
        WScript.Echo "Remote Control enabled"
        WScript.Echo "User permission required"
        WScript.Echo "View the session"
      Case 4
        WScript.Echo "Remote Control enabled"
        WScript.Echo "User permission not required"
        WScript.Echo "View the session"
    End Select

    WScript.Echo VbCrLf & "** Terminal Services Profile Properties Page**"
    WScript.Echo "** (The ADSI Extension for Terminal Services interface) **"
    WScript.Echo "TerminalServicesProfilePath: " & _
      objItem.TerminalServicesProfilePath
    WScript.Echo "TerminalServicesHomeDirectory: " & _
      objItem.TerminalServicesHomeDirectory
    WScript.Echo "TerminalServicesHomeDrive: " & _
      objItem.TerminalServicesHomeDrive
    WScript.Echo "AllowLogon: " & _
      objItem.AllowLogon

    WScript.Echo VbCrLf & "** COM+ Properties Page**"
    WScript.Echo "** (Single-Valued Attributes) **"
    WScript.Echo "msCOM-UserPartitionSetLink: "
    WScript.Echo " " & objItem.Get("msCOM-UserPartitionSetLink")

    WScript.Echo VbCrLf & "** Member Of Properties Page**"
    WScript.Echo "** (Single-Valued Attributes) **"
    strprimaryGroupID = objItem.Get("primaryGroupID")
    WScript.Echo "primaryGroupID: " & strprimaryGroupID

    WScript.Echo VbCrLf & "** Member Of Properties Page**"
    WScript.Echo "** (MultiValued Attributes) **"
    strmemberOf = objItem.GetEx("memberOf")
    WScript.Echo "memberOf:"
    For Each Item in strmemberOf
     WScript.Echo vbTab & Item
    Next

    WScript.Echo VbCrLf & "** Object Properties Page**"
    WScript.Echo "** (Single-Valued Attributes) **"
    strwhenCreated = objItem.Get("whenCreated")
    WScript.Echo "whenCreated: " & strwhenCreated
    strwhenChanged = objItem.Get("whenChanged")
    WScript.Echo "whenChanged: " & strwhenChanged

    objItem.GetInfoEx Array("canonicalName"), 0
    WScript.Echo VbCrLf & "** Object Properties Page**"
    WScript.Echo "** (MultiValued Attributes) **"
    strcanonicalName = objItem.GetEx("canonicalName")
    WScript.Echo "canonicalName:"
    For Each Item in strcanonicalName
     WScript.Echo vbTab & Item
    Next

    from : EzAD Scriptomatic

    整理中...


    文章来源:http://ms.mblogger.cn/xuzhong/posts/16800.aspx
  • 相关阅读:
    《Head First 设计模式》 第八、九章 模板方法模式、迭代器模式、组合模式
    《Head First 设计模式》 第十、十一章 状态模式、代理模式
    《Head First 设计模式》 第六、七章 命令模式、适配器模式、外观模式
    《Head First 设计模式》 第四、五章 工厂模式、单例模式
    敏捷软件开发 第十章、第十一章、第十二章
    《Head First 设计模式》 第二、三章 观察者模式、装饰者模式
    二叉树-面试题27-二叉树的镜像
    堆栈-155-最小栈
    堆栈-20-有效括号
    java编程基础(六)----泛型
  • 原文地址:https://www.cnblogs.com/xuzhong/p/232225.html
Copyright © 2011-2022 走看看