{"id":2770,"date":"2014-04-08T02:34:15","date_gmt":"2014-04-08T02:34:15","guid":{"rendered":"https:\/\/www.wapshere.com\/missmiis\/?p=2770"},"modified":"2014-04-08T02:35:12","modified_gmt":"2014-04-08T02:35:12","slug":"finding-connector-space-objects-with-a-manager-when-the-metaverse-object-has-none","status":"publish","type":"post","link":"https:\/\/www.wapshere.com\/missmiis\/finding-connector-space-objects-with-a-manager-when-the-metaverse-object-has-none","title":{"rendered":"Finding Connector Space objects with a Manager when the Metaverse object has none"},"content":{"rendered":"<p>I was asked to evaluate the impact of ticking &#8220;Allow Nulls&#8221; on the AD export flow for &#8216;manager&#8217; when it was realised that some people had a manager set in AD, while in FIM they had none.<\/p>\n<p>This can be a hard change to test in Dev or Test environments which don&#8217;t have the full set of production data. However if you make the change in Production you may well find yourself with a lot of undesired exports queued. So before doing anything I wanted to get an idea about how many people have a manager set in AD, but none in the Metaverse.<\/p>\n<p><!--more--><\/p>\n<p>The following script starts from a dump of the AD connector space produced using csexport.exe. I then run SQL queries against the FIMSynchronizationService database to fill in the Metaverse half of the story.<\/p>\n<p>Whenever querying the\u00c2\u00a0FIMSynchronizationService database it is important to remember the possibility of locking. I ran this script at a time I knew no syncs were going to run. You could also query a recent replica of the database, or modify the queries in the script to use NOLOCK.<\/p>\n<p>Here&#8217;s the script:<\/p>\n<pre>###\r\n### This script compares Connector Space objects to Metaverse objects for the purpose of finding users with 'manager'\r\n### set in the Connector Space but not set in the Metaverse. This will allow us to judge the impact of enabling\r\n### \"Allow Nulls\" on the EAF before actually doing it.\r\n###\r\n\r\n## csexport.xml must have been produced by running csexport.exe from &lt;Sync Program Folder&gt;\\Bin and exporting the connector space.\r\n[xml]$CS = get-content D:\\Scripts\\csexport.xml\r\n\r\n##\r\n## Create a CSV file from the XML which includes only connectors that have a manager in the connector space\r\n##\r\n$CSVFile = \"D:\\Scripts\\CSmanager.csv\"\r\n\"csid;dn;manager\" | out-file $CSVFile -Encoding Default\r\n\r\nforeach ($connector in $CS.\"cs-objects\".\"cs-object\" | where {$_.\"object-type\" -eq \"user\" -and $_.connector -eq \"1\"})\r\n{\r\n    if ($connector.\"unapplied-export-hologram\".entry.\"dn-attr\" | where {$_.name -eq \"manager\"})\r\n    {\r\n        $manager = ($connector.\"unapplied-export-hologram\".entry.\"dn-attr\" | where {$_.name -eq \"manager\"}).\"dn-value\".dn\r\n        $dn = $connector.\"cs-dn\"\r\n        $csid = $connector.id.Replace(\"{\",\"\").Replace(\"}\",\"\")\r\n        $csid + \";\" + $dn + \";\" + $manager | add-content $CSVFile\r\n    }\r\n}\r\n\r\n##\r\n## Next we query SQL for each line in the CSV. As we are querying the Metaverse tables this should only be done when\r\n## no sync operations are running. Or take a copy of the tables referenced and put them in another DB to query them there,\r\n## or modify the queries to use NOLOCK.\r\n##\r\n\r\n## Load SQL snapins. SQL Management tools must be installed, or you can copy the CSV to the SQL server\r\n## and run this bit of the script there.\r\nif(@(get-pssnapin | where-object {$_.Name -eq \"sqlserverprovidersnapin100\"} ).count -eq 0) {add-pssnapin sqlserverprovidersnapin100}\r\nif(@(get-pssnapin | where-object {$_.Name -eq \"sqlservercmdletsnapin100\"} ).count -eq 0) {add-pssnapin sqlservercmdletsnapin100}\r\n\r\n## Path to your FIMSynchronizationService database\r\nset-location SQLSERVER:\\SQL\\MySQLServer\\Default\\Databases\\FIMSynchronizationService\r\n\r\n## Import CSV file created above\r\n$CSV = import-csv $CSVFile -Delimiter \";\"\r\n\r\n## Create a new CSV file with an extra column showing if manager exists in the Metaverse\r\n$CSVFile = \"D:\\Scripts\\CSmanager-CompareMV.csv\"\r\n\"csid;dn;manager;InMV\" | out-file $CSVFile -Encoding Default\r\n\r\nforeach ($row in $CSV)\r\n{\r\n    ## Get metaverse objectid from CS objectid\r\n    $SQLGetMVID = \"select object_id from dbo.mms_metaverse join dbo.mms_csmv_link on object_id = mv_object_id where cs_object_id = '{0}'\" -f $row.csid\r\n    $mvid = (Invoke-SQLCmd $SQLGetMVID -SuppressProviderContextWarning).\"object_id\"\r\n    $mvid.Guid\r\n\r\n    if ($mvid)\r\n    {\r\n        ## Queries Metaverse reference table and returns 0 for no manager and 1 if there is a manager. \r\n        $SQLHasManager = \"select count (*) from dbo.mms_mv_link where object_id = '{0}' and attribute_name = 'manager'\" -f $mvid.Guid\r\n        $count = (Invoke-SQLCmd $SQLHasManager -SuppressProviderContextWarning).Column1\r\n        $count\r\n    }\r\n    else {$count = \"0\"}\r\n\r\n    $row.csid + \";\" + $row.dn + \";\" + $row.manager + \";\" + $count | add-content $CSVFile\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I was asked to evaluate the impact of ticking &#8220;Allow Nulls&#8221; on the AD export flow for &#8216;manager&#8217; when it was realised that some people had a manager set in AD, while in FIM they had none. This can be a hard change to test in Dev or Test environments which don&#8217;t have the full&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[42,60,58,15,23,61,5],"tags":[],"class_list":["post-2770","post","type-post","status-publish","format-standard","hentry","category-fim-2010","category-fim-2010-r2","category-fim-sync-service","category-ilm","category-powershell","category-reporting","category-sql"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pkp1o-IG","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2770","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/comments?post=2770"}],"version-history":[{"count":3,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2770\/revisions"}],"predecessor-version":[{"id":2773,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/posts\/2770\/revisions\/2773"}],"wp:attachment":[{"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/media?parent=2770"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/categories?post=2770"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wapshere.com\/missmiis\/wp-json\/wp\/v2\/tags?post=2770"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}