Infra has been a great ITIL toolset for my department. The only downfall I have run into is some of the simpler integrations or features come at a steep price point. This integration cannot be that far out of the box for Infra but yet costs thousands of dollars. Instead I have been spending some time understanding the Infra database and have come up with the following VBS to move the manager information stored in AD into the Infra database. We have this script to run each night and it keeps everything in order.
LDAPRootDN = "LDAP://OU=HCL Users,DC=hcl,DC=internal"
' Infra database DSN
InfraDSN = "Driver={SQL Server};Server=data01.hcl.internal;Database=infraEnterprise;Trusted_Connection=TRUE"
set objConnection = CreateObject("ADODB.Connection")
objConnection.ConnectionString = InfraDSN
objConnection.open
' Start the process
ProcessOU(LDAPRootDN)
function ProcessOU ( DN )
set CNUsers = GetObject(DN)
for each User in CNUsers
select case User.class
case "user"
' Migrate manager information if a manager is defined
if ( User.manager <> "" ) then
MigrationCount = MigrationCount + 1
MigrateManager User.distinguishedName, User.manager
else
' No manager information on file
end if
case "organizationalUnit", "container"
' This is an OU, recurse into
ProcessOU( User.ADsPath )
end select
next
end function
function MigrateManager ( StaffDN, ManagerDN )
set Staff = GetObject("LDAP://" + StaffDN)
set Manager = GetObject("LDAP://" + ManagerDN)
strQuery = "exec sp_MigrateManager '" + Staff.GUID + "', '" + Manager.GUID + "'"
set rs = objConnection.execute(strQuery)
end function
The following is the supporting TSQL for the sp_MigrateManager procedure.
USE infraEnterprise
GO
IF EXISTS ( (SELECT NAME FROM sysobjects WHERE NAME = 'sp_MigrateManager' AND TYPE = 'P'))
BEGIN
DROP PROCEDURE sp_MigrateManager
END
GO
CREATE PROCEDURE sp_MigrateManager
@StaffGUID NVARCHAR(300),
@ManagerGUID NVARCHAR(300)
AS
BEGIN
DECLARE @ManagerRef INT
SELECT @ManagerRef = COALESCE(REF, 0) FROM AR_USER_ATTRIBUTES WHERE ldap_object_id = @ManagerGUID
UPDATE AR_USER_ATTRIBUTES
SET
MANAGER_REF = @ManagerRef
WHERE
ldap_object_id = @StaffGUID
END
GO