+ Post New Thread
Results 1 to 3 of 3
Network and Classroom Management Thread, Lanview AD integration in Technical; I'm trying to implement the Active Directory integration script that is on the Lanview community forums and I have a ...
  1. #1
    Andi's Avatar
    Join Date
    Feb 2007
    Location
    Newport, South Wales
    Posts
    276
    Thank Post
    52
    Thanked 4 Times in 4 Posts
    Rep Power
    15

    Lanview AD integration

    I'm trying to implement the Active Directory integration script that is on the Lanview community forums and I have a slight problem.

    The script runs with no problem and successfuly queries my AD, however the structure written back to Lanview isn't quite as I need it to be, due to the way my AD is organised.

    Currently the OUs I'm getting created in Lanview by the script are:
    Domain Controllers
    Member Servers
    Network Computers
    Network Tool Stations
    Staff
    Students

    These are all top level OUs, and all have sub-containers. It is specifically the Sub-OUs of 'Network Computers' that I really want to appear and be populated in LanView and the others can all be ignored by the script.

    Is this possible?

    Here is the script that is called at program startup (I'm sure that the AD scripting can be tweaked by some knowledgable soul on here):
    Code:
    '=========================================================================
    ' AUTHOR: Jose Mosquera 
    ' DATE: 16/12/2006
    '
    ' PURPOSE: Connect to AD Root, enumerate each OU to enumerate all computers
    ' in each OU, read the host name, then
    ' generate a report text file with all the OU's and computers and
    ' their properties.
    '
    ' COMMENT: 
    '=========================================================================
    Option Explicit
    Dim objRootDSE
    Dim objDomain
    Dim objContainer
    Dim objOU
    Dim objComputers
    Dim objShell
    Dim objReportFile
    ReDim arrComputers(100,1)
    ReDim arrOUs(100,1)
    Dim strPrompt
    Dim strCurDir
    Dim intRetVal
    Dim intCount
    Dim intX
    Dim intY
    Dim strDummy
    Dim GroupsFile
    
    strDummy = """" & "~Dummy" & """"
    GroupsFile = "Groups.bind"
    
    ' Connect to AD Root.
    Set objRootDSE = GetObject("LDAP://RootDSE")
    ' Get domain name.
    Set objDomain = GetObject("LDAP://" & objRootDSE.Get("DefaultNamingContext"))
    ' Call Sub that will list each OU.
    Call EnumOUs(objDomain.ADsPath)
    
    CreateGroupsFile ' Create text file to host found data.
    DisplayADObjects ' Call notepad and display text file to user.
    
    '--------------------------------------------------------------------------------------------------
    ' ====================================================================================
    ' TITLE: EnumOUs
    '
    ' PURPOSE: Loop through all OU container from Active Directory Root 
    ' and pass current found OU to EnumComputers
    '
    ' HOW TO USE: Call EnumOUs(objOU.ADsPath)
    '
    ' ====================================================================================
    Sub EnumOUs(sADsPath)
    ' Connect to Active Directory First Container.
    Set objContainer = GetObject(sADsPath)
    ' Filter to only Organizational Unit.
    objContainer.Filter = Array("OrganizationalUnit")
    intX=0
    intY=0
    For Each objOU in objContainer
    	If objOU.Name <> "OU=Printers" AND objOU.Name <> "OU=MyBusiness" then
    	      arrOUs(intX,0) = strDummy
    	      arrOUs(intX,1) = """" & Mid(objOU.Name, 4) & """"
    	      EnumComputers(objOU.ADsPath) ' If there are Computers in this OU, will extract them.
    	      intX = intX + 1
    	End If
    Next
    
    End Sub
    '--------------------------------------------------------------------------------------------------
    ' ====================================================================================
    ' TITLE: EnumComputers
    '
    ' PURPOSE: Loop through all user container in each OU and create an 
    ' array with some properties for each computer.
    '
    ' HOW TO USE: Call EnumComputers(objOU.ADsPath)
    '
    ' ====================================================================================
    Sub EnumComputers(sADsPath)
    ' sADsPath contain current OU from EnumOUs. Connect to it.
    Set objContainer = GetObject(sADsPath)
    ' Filter only computer objects
    objContainer.Filter = Array("Computer")
    ' Extract Computer Name only
    For Each objComputers in objContainer
    	arrComputers(intY,0) = """" & Mid(objComputers.Name, 4) & """"
    	arrComputers(intY,1) = arrOUs(intX,1)
    	'Msgbox arrComputers(intY,0) & " " & arrComputers(intY,1)
    	intY = intY + 1
    Next
    
    End Sub
    '--------------------------------------------------------------------------------------------------
    ' ====================================================================================
    ' TITLE: CreateGroupsFile
    '
    ' PURPOSE: Create a Groups.bind file hosting data from Active Directory Computers
    ' in any OUs
    '
    ' HOW TO USE: Call CreateGroupsFile
    '
    ' ====================================================================================
    Sub CreateGroupsFile
    Dim objFSO
    Dim strReportFile
    
    Set objShell = CreateObject("WScript.Shell")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    ' Get directory from where this script is executed.
    
    strReportFile = "C:\Program Files\LanView3 Server\Bindaries\" + GroupsFile
    
    Set objReportFile = objFSO.CreateTextFile(strReportFile, True)
    End Sub
    '--------------------------------------------------------------------------------------------------
    ' ====================================================================================
    ' TITLE: DisplayADObjects
    '
    ' PURPOSE: Write report of all computers found in Active Directory.
    '
    ' HOW TO USE: Call DisplayADObjects
    '
    ' ====================================================================================
    Sub DisplayADObjects
    
    ' Add Default groups as seen in standard LANVIWEW SERVER.
    	objReportFile.WriteLine (strDummy & ","  & """" & "IAM Disabled" & """") 
    	objReportFile.WriteLine (strDummy & ","  & """" & "IAM Ignored" & """") 
    	objReportFile.WriteLine (strDummy & ","  & """" & "IAM Managers" & """") 
    	objReportFile.WriteLine (strDummy & ","  & """" & "Watched Object" & """") 
    	objReportFile.WriteLine (strDummy & ","  & """" & "Known PC's" & """") 
    
    'Output the OU's Name
    For intCount = 0 To UBound(arrOUs)
    If Not IsNoData(arrOUs(intCount,0)) Then
    	objReportFile.WriteLine(arrOUs(intCount,0) & "," & arrOUs(intCount,1))
    End If
    Next
    
    
    ' Add each computer found in AD.
    For intCount = 0 To UBound(arrComputers)
    'Verify each value in arrComputers. Write only if there is data.
    If Not IsNoData(arrComputers(intCount,0)) Then
    	objReportFile.WriteLine(arrComputers(intCount,0) & "," & arrComputers(intCount,1))
    End If
    Next
    
    objReportFile.Close
    End Sub
    ' ====================================================================================
    ' TITLE: IsNoData
    '
    ' PURPOSE: Verify if passed parameter variable contain something.
    '
    ' RETURN: True if contain something, otherwise, False.
    '
    ' HOW TO USE: intResult = IsNoData(varSource) or
    ' If IsNoData(varSource) Then do something.
    '
    ' AUTHOR: Christian Sawyer
    ' ====================================================================================
    Function IsNoData(varVal2Check)
    'Verify if varVal2Check contain something.
    On Error Resume Next
    If IsNull(varVal2Check) Or IsEmpty(varVal2Check) Then
    IsNoData = True
    Else
    If IsDate(varVal2Check) Then
    IsNoData = False
    ElseIf varVal2Check = "" Then
    IsNoData = True
    ElseIf Not IsObject(varVal2Check) Then
    IsNoData = False
    Else
    IsNoData = False
    End If
    End If
    End Function

  2. #2

    Join Date
    Jul 2005
    Location
    Rugby
    Posts
    432
    Thank Post
    17
    Thanked 66 Times in 61 Posts
    Rep Power
    35

    Re: Lanview AD integration

    Been playing a bit with some of my vbscripts this week so i'm quite fresh atm

    If you change the following line:
    Set objRootDSE = GetObject("LDAP://RootDSE")
    To:
    Set objRootDSE = GetObject("LDAP://ou=Network Computers,ou=ParentOU,dc=DOMAIN,dc=NAME")
    Obviously adapting to your specific ad structure.

    That should only query your networked computers ou and sub ou's.

    Matt

  3. #3
    Andi's Avatar
    Join Date
    Feb 2007
    Location
    Newport, South Wales
    Posts
    276
    Thank Post
    52
    Thanked 4 Times in 4 Posts
    Rep Power
    15

    Re: Lanview AD integration

    Thanks,
    I've changed the line you mentioned so that it reads:
    Code:
    ' Connect to AD Root.
    Set objRootDSE = GetObject("LDAP://ou=Network Computers,dc=Monmouth,dc=LOCAL")
    but the line after it:
    Code:
    ' Get domain name.
    Set objDomain = GetObject("LDAP://" & objRootDSE.Get("DefaultNamingContext"))
    now complains with the error 'The directory property cannot be found in the cache'.

SHARE:
+ Post New Thread

Similar Threads

  1. vle's mis integration
    By plexer in forum Virtual Learning Platforms
    Replies: 37
    Last Post: 7th August 2011, 08:23 PM
  2. The end of Lanview?
    By ShorehamGeek in forum Network and Classroom Management
    Replies: 38
    Last Post: 10th March 2009, 10:42 AM
  3. Lanview password
    By kevin in forum Network and Classroom Management
    Replies: 4
    Last Post: 17th May 2007, 02:14 PM
  4. Lanview
    By mrtechsystems in forum Thin Client and Virtual Machines
    Replies: 3
    Last Post: 22nd March 2007, 10:25 AM
  5. SIMS AD Integration
    By mark in forum MIS Systems
    Replies: 3
    Last Post: 11th November 2006, 12:24 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •