Highlighted
Flexera beginner

FNMS - Would like to assign Corp Unit based on domain name -

Multiple Beacon installs across operating divisions each with different domain names, has anyone been successful in writing an adapter that could do corp unit assignment during inventory discovery?

0 Kudos
2 Replies
Highlighted
Community Manager Community Manager
Community Manager

Re: FNMS - Would like to assign Corp Unit based on domain name -

An approach with FlexNet Manager Suite On-premises to doing this would be to configure a business adapter that retrieves inventory device (aka "computer") record information from the Compliance database, maps the domain details to corporate units, and updates the corporate unit details on the source inventory device records.

With that said, I don't have an example of such an adapter to share sorry. However I do have a SQL script (below) which does a similar thing - it sets locations on records rather than corporate units, but it would be straightforward to change which property is set if you are familiar with working with the database schema.

NB. The fact I'm sharing a SQL script to do this doesn't mean this is the best way to do it. Directly manipulating SQL data like this in the Compliance database is not a great practice (e.g. there is no guarantee that the script will continue to work across different or future FlexNet Manager Suite releases). However I'm sharing this because it is the only sample I have doing a similar thing so hopefully it is of some help.

-- This  script will move computer (inventory device) records to a location,
-- based on rules specified in the mapping populated into the
-- #CustomNameDomainToLocationMap table below.
--
-- This script is known to work with FlexNet Manager Suite 2018 R2.
 
IF OBJECT_ID('tempdb..#CustomNameDomainToLocationMap') IS NULL
BEGIN
	-- The #CustomNameDomainToLocationMap table defines domain name and
	-- computer name patterns that are mapped to specific locations. In the
	-- case where a particular computer matches multiple mappings, the mapping
	-- with the smallest priority value (= highest priority) is chosen.

	CREATE TABLE #CustomNameDomainToLocationMap(
		DomainPattern NVARCHAR(100) COLLATE DATABASE_DEFAULT NOT NULL
		, NamePattern NVARCHAR(256) COLLATE DATABASE_DEFAULT NOT NULL
		, LocationPath NVARCHAR(500) COLLATE DATABASE_DEFAULT NOT NULL
		, Priority INT NOT NULL
	)

	INSERT #CustomNameDomainToLocationMap VALUES ('china.com', '%', 'Asia Pacific/China', 1)
	INSERT #CustomNameDomainToLocationMap VALUES ('india.com', '%', 'Asia Pacific/India', 1)
	INSERT #CustomNameDomainToLocationMap VALUES ('mexico.com', '%', 'Americas/Mexico', 1)
	INSERT #CustomNameDomainToLocationMap VALUES ('manila.com', '%', 'Asia Pacific/Philippines/Manila', 1)
	INSERT #CustomNameDomainToLocationMap VALUES ('%', 'mlb%', 'Asia Pacific/Australia/Melbourne', 2)
END


IF OBJECT_ID('tempdb..#Target') IS NOT NULL
	DROP TABLE #Target

CREATE TABLE #Target(
	TargetID INT
	, TargetTypeID INT
	, GroupExID VARCHAR(128) COLLATE DATABASE_DEFAULT
	, GroupTypeID INT
)


BEGIN TRANSACTION

; WITH DesiredLocation AS (
	SELECT TOP 1 WITH TIES
		cc.ComplianceComputerID
		, LocationID = ml.GroupExID
		, ROW_NUMBER() OVER(PARTITION BY cc.ComplianceComputerID ORDER BY m.Priority) AS Ranking
	FROM dbo.ComplianceComputerWithActiveInventory cc
		LEFT OUTER JOIN dbo.ComplianceDomain cd ON cd.ComplianceDomainID = cc.ComplianceDomainID
		INNER JOIN (
			#CustomNameDomainToLocationMap m
			INNER JOIN dbo.GroupEx ml ON ml.Path = m.LocationPath AND ml.GroupTypeID = 1 /* location */
		) ON cc.ComputerName LIKE m.NamePattern AND ISNULL(cd.QualifiedName, '') LIKE m.DomainPattern
	ORDER BY Ranking
)
UPDATE cc
SET LocationID = dl.LocationID
OUTPUT INSERTED.ComplianceComputerID, tt.TargetTypeID, INSERTED.LocationID, 1 /* location */ INTO #Target
FROM DesiredLocation dl
	JOIN dbo.ComplianceComputer cc ON cc.ComplianceComputerID = dl.ComplianceComputerID AND ISNULL(cc.LocationID, '') != dl.LocationID
	, dbo.TargetType tt
WHERE	tt.TargetTypeName = 'ComplianceComputer'


PRINT N'Moved ' + CAST(@@ROWCOUNT AS nvarchar(255)) + N' ComplianceComputer records to a better location'

EXEC dbo.GroupExUpdateGroupMembershipBulk

DROP TABLE #Target


UPDATE a
SET LocationID = cc.LocationID
FROM dbo.Asset a
	JOIN dbo.ComplianceComputerWithActiveInventory cc
		ON cc.AssetID = a.AssetID
		AND cc.LocationID != ISNULL(a.LocationID, '')

PRINT N'Synchronized location from ' + CAST(@@ROWCOUNT AS nvarchar(255)) + N' ComplianceComputer records to linked Asset records'

/*
NB. It is not necessarily to call GroupExUpdateGroupMembershipBulk here to
update group membership details for updated assets, since there is a
built-in "UpdateAssetGroupMembership" trigger that does that automatically.
There is no similar trigger for ComplianceComputer, which is why an explicit
call to GroupExUpdateGroupMembershipBulk is required above.
*/

COMMIT TRANSACTION

 

(Anything expressed here is my own view and not necessarily that of my employer, Flexera. If my reply answers a question you have raised, please click "ACCEPT AS SOLUTION".)
Highlighted
Consultant

Re: FNMS - Would like to assign Corp Unit based on domain name -

Hi @alisabrown2074 

I implemented something like this into an on Prem solution.

To implement this I had the following:

An mapping table where I map the domain and the corporate unit.

Something like:

xxx.yyy domain is xxx corp unit

zzz.yyy domain is zzz corp unit

Using following custom view

SELECT        FNMP.dbo.ComplianceComputer.ComplianceDomainID, FNMP.dbo.ComplianceDomain.ComplianceDomainID AS Expr1, FNMP.dbo.ComplianceDomain.QualifiedName, dbo.cu_domain.Domain, 

                         dbo.cu_domain.[Corporate Unit FNMS], FNMP.dbo.ComplianceComputer.ComputerName, FNMP.dbo.ComplianceComputer.AssetID, FNMP.dbo.ComplianceComputer.ComplianceComputerStatusID, 

                         FNMP.dbo.CorporateUnit.GroupCN, FNMP.dbo.ComplianceComputer.BusinessUnitID

FROM            dbo.cu_domain INNER JOIN

                         FNMP.dbo.ComplianceDomain INNER JOIN

                         FNMP.dbo.ComplianceComputer ON FNMP.dbo.ComplianceDomain.ComplianceDomainID = FNMP.dbo.ComplianceComputer.ComplianceDomainID ON 

                         dbo.cu_domain.Domain = FNMP.dbo.ComplianceDomain.QualifiedName INNER JOIN

                         FNMP.dbo.CorporateUnit ON FNMP.dbo.ComplianceComputer.BusinessUnitID = FNMP.dbo.CorporateUnit.GroupExID

WHERE        (FNMP.dbo.ComplianceComputer.AssetID IS NULL) AND (FNMP.dbo.ComplianceComputer.ComplianceComputerStatusID = 1 OR

                         FNMP.dbo.ComplianceComputer.ComplianceComputerStatusID = 2) AND (FNMP.dbo.ComplianceComputer.BusinessUnitID IS NULL

 

Cu_domain is the mapping table that I use, having the 2 column Domain, Corporate Unit FNMS

Using this I filter out the data that have an asset assigned and a corporate unit assigned, remaining inventory are subject of the mapping table

 Now after I have this set of data, I write a custom business importer that contain

Corporate unit and Computer items,  using only update on corporate unit.

You should also take note that this is working only if you don't have an asset linked with inventory, if you have the asset linked all modification regarding corporate unit and stuff should be taken into your CMDB source.

You should thread this as a work around and is not sure if in future FNMS release this will work.