' Customer function for collecting custom inventory.
Private Function GetDefaultUSer()
Dim sxmlFile, oNodeList, sUser
If bStatus Then bStatus=Job_WriteLog("GetDefaultUSer","Get default user",bStatus,True)
sxmlFile=gsWorkstationpath & "Agent\" & gsWorkstationname & ".lgi"
Set oxmlDoc = CreateObject("Msxml2.DOMDocument")
If isObject(oxmlDoc) Then
Set oNodeList = oxmlDoc.selectNodes("//Inventory/Section [@Value= " & Chr(34) & "Default User" & Chr(34) & "]")
For each oNode in oNodelist
sUser=Trim(Mid(oNode.Text,1,Instr(oNode.Text," ")-1))
If bStatus Then bStatus=Job_WriteLog("GetDefaultUSer","Found default user '" & sUser & "'",bStatus,True)
Function GetDepartment(sUser)
Dim bStatus, objUser, sDept
If bStatus Then bStatus=Job_WriteLog("GetDepartment","Get default user department",bStatus,True)
Set objUser = GetObject("LDAP://cn=" & sUser & ",cn=USERS,dc=Test,dc=local")
If isObject(objUser) Then
sDept=objUser.Get("department")
If bStatus Then bStatus=Job_WriteLog("GetDepartment","Default user department '" & sDept & "'",bStatus,True)
Private Function CustomInventory()
On Error Resume Next 'Avoid runtime errors
bStatus=True 'initialize as True
If bStatus Then bStatus=Job_WriteLog("CustomInventory","Custom Inventory Script build " & sBuild,bStatus,True)
If bStatus Then sUser=GetDefaultUSer()
If bStatus and (sUser<>"") Then
If bStatus Then sDept=GetDepartment(sUser)
If bStatus and (sDept<>"") Then
If bStatus Then bStatus=Ini_WriteEntry(gsWorkstationPath & "Agent\" & gsWorkstationName & ".csi","Customer Inventory","Department",sDept)
If bStatus Then bStatus=Job_WriteLog("CustomInventory","Custom Inventory Script end.",bStatus,True)