Home > Development, Infra > Migrating AD Manager information into Infra

Migrating AD Manager information into Infra

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
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
Categories: Development, Infra Tags:
  1. Syed Jawwad Hussain
    June 3rd, 2010 at 01:21 | #1

    Kurt,

    I was searching for infraEnterprise and came across your blog through google. I have implemented about 3 new infraEnterprise System and have provided numerous customizations (Customized Workflows using Stored Procedures and APIs, customized reports, customized new screens using htm, javascript and SQL). Have been working with infra for the past two years.

    I saw the customization that you listed on your website but cannot understand the purpose of it. I have not worked extensively with the AD integration other than out-of-box functionality. Couldnt you acheive this through the custom.ldap file where you can define your own parameters?

    Sincerely,

    Jawwad

  1. No trackbacks yet.