5 Replies Latest reply on Sep 6, 2014 2:09 PM by dblansky

    How do I query the department column in Active Directory?

    Tazangel Apprentice

      How do I query the department column in Active Directory?

       

      I'm using LDMS 9.5.

        • 1. Re: How do I query the department column in Active Directory?
          ldms_4mfe Apprentice

          There is a shipped Rule Data Analytics - Data Translation Service Rule -  "Integrate %DOMAIN% User Information"

          " LDAP-Import > All Rules > ..."

           

          This rule imports a lot of AD-Fields to the Computer.Owner Category.

          • 2. Re: How do I query the department column in Active Directory?
            Tazangel Apprentice

            I'm not running Data Analytics add-on.

            • 3. Re: How do I query the department column in Active Directory?
              Tazangel Apprentice

              I just need to edit the "LDAP User" section in a new query and add "Department".

              • 4. Re: How do I query the department column in Active Directory?
                Alex.Richardson SSMMVPGroup

                You dont want to add data directly in the console as if the computer object is deleted you lose that data. The best way without Data Analytics is to create an entry in the devices registry that you can bring back as custom data in LDMS. You can then query on this field.

                The hard part will be working out how to query AD from the client to obtain the department and then write this to the registry.

                 

                I would take a look at Data Analytics as this will give you what you want straight away plus much more functionality and enhanced inventory info.

                • 5. Re: How do I query the department column in Active Directory?
                  Specialist

                  I have a VBS script that I patched together from a couple of MS threads to add the LDAP values I needed to the HKCU key in the registry.  I then added a custom reg scan to capture the values to the Custom Data section of my inventory.

                  It also sets the user's name & initials into MS Office - it is in the startup folder:

                   

                  On Error Resume Next

                  Dim objSysInfo, objUser

                  Set objSysInfo = CreateObject("ADSystemInfo")

                   

                  ' Currently logged in User

                  strUser = objSysInfo.UserName

                  Set objUser = GetObject("LDAP://" & strUser)

                  Set objWord = CreateObject("Word.Application")

                   

                  ' Create a WSH Shell object:

                  Set wshShell = CreateObject( "WScript.Shell" )

                   

                  ' Create a new HKCU\JHL_LDAP_Info key & set variables

                  wshShell.RegWrite "HKCU\COMPANY_LDAP_Info\", ""

                  firstname = objUser.givenname

                  lastname = objUser.sn

                  department = objUser.department

                  office = objUser.physicalDeliveryOfficeName

                  title = objUser.title

                   

                  ' Create new string values in that new subkey:

                  wshShell.RegWrite "HKCU\COMPANY_LDAP_Info\" & "FirstName", firstname, "REG_SZ"

                  wshShell.RegWrite "HKCU\COMPANY_LDAP_Info\" & "LastName", lastname, "REG_SZ"

                  wshShell.RegWrite "HKCU\COMPANY_LDAP_Info\" & "Department", department, "REG_SZ"

                  wshShell.RegWrite "HKCU\COMPANY_LDAP_Info\" & "Title", title, "REG_SZ"

                  wshShell.RegWrite "HKCU\COMPANY_LDAP_Info\" & "Office", office, "REG_SZ"

                   

                  ' Set Office Name & Initials

                  ' There are two methods below to write the user info. The first (and active) is a combination of GiveName and SN

                  ' The second is the same, but it capitalizes the first character and sets the rest to lowercase for when

                  ' your AD environment does not use capitalization for those two fields.  Switch the comment tags around to

                  ' enable the 2nd one.

                   

                  objWord.UserName = objUser.givenName & " " & objUser.SN

                   

                  ' objWord.UserName = Ucase(Left(objUser.givenName, 1)) & Lcase(Right(objUser.givenName, Len(objUser.givenName) – 1)) & " " & Ucase(Left(objUser.SN, 1)) & Lcase(Right(objUser.SN, Len(objUser.SN) – 1))

                   

                  objWord.UserInitials = Left(objUser.givenName, 1) & Left(objUser.SN, 1)

                  ' objWord.UserInitials = Ucase(Left(objUser.givenName, 1)) & Ucase(Left(objUser.SN, 1))

                   

                  objWord.Quit