No announcement yet.

vbscript and ad

  • Filter
  • Time
  • Show
Clear All
new posts

  • vbscript and ad

    How could I get information of which logon script each user has in AD. I have vbscript that I have managed to get display names but I can't get the names of logon scripts.
    Thanks in advance.

  • #2
    Re: vbscript and ad

    Are you after the different logon script(s) that is associated with each user?

    jan - marketing.bat
    jenny - support.bat
    jill - sales.bat
    joe - accounts.bat
    june - admin.bat

    Your question wasn't really very clear.
    1 1 was a racehorse.
    2 2 was 1 2.
    1 1 1 1 race 1 day,
    2 2 1 1 2


    • #3
      Re: vbscript and ad

      Yes that is exactly what I mean. Except it's
      jenny - support.vbs
      jill - sales.vbs
      joe - accounts.vbs
      june - admin.vbs
      But that doesn't matter.
      I need to list all users from ad and which logon script is associated to them.
      I'm sorry if I wasn't clear enough.
      I'm able to list all users but how to get the logon scripts. The display name I can get with objMember.DisplayName


      • #4
        Re: vbscript and ad

        The User attribute you are looking for is scriptPath (objUser.scriptPath)

        - (very nice)

        ' This script Search the AD for Userobjects that have 
        ' a logonscript configured in the profile tab in ADU&C.
        ' The LDAP://RootDSE has an outstanding reference to the server.
        ' Therefor the different GetObject calls won't create extra binds.
        Set objRootDSE = GetObject("LDAP://rootDSE")
        strDNSDomain = objRootDSE.Get("defaultNamingContext")
        'Start the ADO connection
        Set objCommand = CreateObject("ADODB.Command")
        Set objConnection = CreateObject("ADODB.Connection")
        objConnection.Provider = "ADsDSOObject"
        objConnection.Open "Active Directory Provider"
        objCommand.ActiveConnection = objConnection
        'Set the ADO connection query strings
        QueryPath = "" & strDNSDomain
        strFilter = "(&(objectCategory=person)(objectClass=user)(scriptPath=*))"
        strAttributes = "adspath"
        'Create the LDAP-Query
        strQuery = "<LDAP://" & QueryPath & ">;" & strFilter & ";" _
                    & strAttributes & ";subtree"
        objCommand.CommandText = strQuery
        objCommand.Properties("Page Size") = 100
        objCommand.Properties("Timeout") = 30
        objCommand.Properties("Cache Results") = False
        Set objRecordSet = objCommand.Execute
        If not objRecordSet.eof then 
          While Not objRecordset.EOF
            strItemPath = objRecordSet.Fields("AdsPath").Value
            Set objItem = GetObject(strItemPath)
            ResultsLst = _
                    ResultsLst & objItem.CN & vbTab & objItem.scriptPath & vbNewLine
            Set objItem = Nothing
        End If
        wscript.echo ResultsLst
        Last edited by Rems; 31st August 2008, 21:45. Reason: added extra link

        This posting is provided "AS IS" with no warranties, and confers no rights.


        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts


        • #5
          Re: vbscript and ad

          Originally posted by rems
          DAMN!! It is very nice isn't it. Excellent find!
          1 1 was a racehorse.
          2 2 was 1 2.
          1 1 1 1 race 1 day,
          2 2 1 1 2


          • #6
            Re: vbscript and ad

            Originally posted by biggles77 View Post
            DAMN!! It is very nice isn't it. Excellent find!
            Agreed, awesome find.
            ** Remember to give credit where credit is due and leave reputation points where appropriate **


            • #7
              Re: vbscript and ad

              Indeed useful.
              Thread updated.
              Technical Consultant

              MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
              "No matter how secure, there is always the human factor."

              "Enjoy life today, tomorrow may never come."
              "If you're going through hell, keep going. ~Winston Churchill"