Home
%3CLINGO-SUB%20id%3D%22lingo-sub-898424%22%20slang%3D%22en-US%22%3EHow%20to%20Restrict%20Access%20to%20AIP%20Audit%20Logs%20to%20a%20Single%20Country%20or%20Region.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-898424%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20the%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FAzure-Information-Protection%2FHow-to-Build-a-Custom-AIP-Tracking-Portal%2Fba-p%2F875849%22%20target%3D%22_blank%22%20rel%3D%22noopener%22%3Efirst%20installment%3C%2FA%3E%20of%20this%203-part%20blog%20series%2C%20we%20showed%20you%20how%20to%20create%20a%20custom%20AIP%20tracking%20portal%20that%20allowed%20end%20users%20to%20see%20access%20activity%20for%20their%20protected%20documents.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EToday%E2%80%99s%20blog%20will%20focus%20on%20how%20you%20can%20empower%20your%20security%20and%2For%20compliance%20professionals%20to%20access%20AIP%20labeling%20activity%20by%20other%20users%20within%20your%20organization.%20But%2C%20with%20an%20added%20bonus.%20The%20sample%20solution%20demonstrates%20how%20you%20could%20ensure%20that%20%3CSTRONG%3Eonly%20the%20right%20administrators%20have%20access%3C%2FSTRONG%3E%20%3CSTRONG%3Eto%3C%2FSTRONG%3E%20user%E2%80%99s%20%3CSTRONG%3Elabeling%20data%3C%2FSTRONG%3E%20and%20%3CSTRONG%3Ewithin%20the%20right%20country%20or%20region%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20today%E2%80%99s%20scenario%2C%20we%20will%20introduce%20you%20to%20three%20personas%20within%20the%20Contoso%20organization.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFirst%2C%20a%20bit%20of%20context%20about%20the%20company%3A%20Contoso%20is%20a%20multinational%20organization%20with%20offices%20across%20%3CSTRONG%3EEurope%20%3C%2FSTRONG%3Eand%20the%3CSTRONG%3E%20United%20States.%20%3C%2FSTRONG%3EDue%20to%20GDPR%20as%20well%20as%20internal%20regulations%2C%20Contoso%20needs%20to%20make%20sure%20that%20compliance%20administrators%20are%20not%20able%20to%20see%20AIP%20labeling%20data%20for%20users%20outside%20their%20own%20country%20or%20region.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20now%20let%E2%80%99s%20meet%20the%20personas%20involved.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EPersona%201%3A%20%3CSTRONG%3EAlex%20Wilber%3C%2FSTRONG%3E%20%E2%80%93%20Alex%20is%20a%20Contoso%20employee%20who%20works%20out%20of%20the%20Munich%20office%20in%20%3CSTRONG%3EGermany%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3EPersona%202%3A%20%3CSTRONG%3EDiego%20Siciliani%3C%2FSTRONG%3E%20%E2%80%93%20Diego%20is%20a%20Contoso%20employee%20who%20works%20out%20of%20the%20Bellevue%20office%20in%20the%20%3CSTRONG%3EUnited%20States%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3EPersona%203%3A%20%3CSTRONG%3EAdele%20Vance%3C%2FSTRONG%3E%20%E2%80%93%20Adele%20is%20a%20Compliance%20professional%20at%20Contoso%20who%20works%20out%20of%20the%20New%20York%20office%20in%20the%20%3CSTRONG%3EUnited%20States%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EAs%20you%E2%80%99re%20probably%20aware%20by%20now%2C%20AIP%20stores%20all%20labeling%20activity%20in%20a%20single%20Log%20Analytics%20Workspace%20within%20a%20selected%20region.%20Although%20there%20we%20provide%20ways%20to%20restrict%20access%20to%20this%20data%20via%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Finformation-protection%2Freports-aip%23permissions-required-for-azure-information-protection-analytics%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3ERBAC%3C%2FA%3E%2C%20it%E2%80%99s%20an%20all%20or%20nothing%20proposition.%20If%20you%20grant%20an%20administrator%20reader%E2%80%99s%20access%20to%20the%20logs%2C%20that%20administrator%20will%20be%20able%20to%20see%20all%20logs%20by%20all%20users%20despite%20the%20user%E2%80%99s%20location.%20%26nbsp%3BLog%20Analytics%20API%20however%2C%20gives%20you%20more%20control%20on%20what%20data%20you%20present%20to%20a%20security%20or%20compliance%20professional%20as%20you%E2%80%99ll%20see%20below.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%E2%80%99s%20look%20at%20the%20requirements.%20This%20solution%20is%20very%20similar%20to%20what%20we%20used%20on%20the%20previous%20user%20portal%20so%20please%20refer%20to%20our%20first%20blog%20for%20more%20details.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAt%20a%20high%20level%20however%2C%20you%20need%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EAn%20application%20registered%20within%20Azure%20AD%20(service%20principal)%3COL%20style%3D%22list-style-type%3A%20lower-alpha%3B%22%3E%0A%3CLI%3EThe%20service%20principal%20needs%20access%20to%20the%20Microsoft%20Graph%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3CLI%3EAzure%20Function%3C%2FLI%3E%0A%3CLI%3ELog%20Analytics%20Workspace%3C%2FLI%3E%0A%3CLI%3EPowerShell%20to%20test%20the%20solution%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3ELet%E2%80%99s%20look%20at%20some%20snippets%20of%20the%20code%20we%20used.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELike%20the%20previous%20user%20portal%20solution%2C%20we%20are%20leveraging%20an%20Azure%20Function%20but%20in%20this%20case%20there%20a%20couple%20of%20new%20features%20you%20would%20want%20to%20pay%20attention%20to.%20In%20this%20example%2C%20Adele%20Vance%20(compliance%20professional)%20wants%20to%20get%20a%20list%20of%20AIP%20files%20that%20were%20protected%20by%20Diego%20(end%20user).%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20comply%20with%20Contoso%E2%80%99s%20policy%2C%20we%20need%20to%20make%20sure%20that%20Adele%20is%20authorized%20to%20access%20Diego%E2%80%99s%20AIP%20labeling%20activity.%20To%20that%20end%2C%20the%20Function%20expects%20to%20receive%20the%20email%20address%20for%20both%20Adele%20(admin)%20and%20Diego%20(user).%20Once%20the%20Function%20receives%20those%20two%20values%2C%20it%20calls%20the%20Microsoft%20Graph%20to%201)%20verify%20Adele%E2%80%99s%20rights%20by%20checking%20her%20group%20membership%20and%20to%20ensure%20both%20users%20are%20located%20within%20the%20same%20country.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EIMPORTANT%3A%3C%2FSTRONG%3E%20While%20there%20are%20plenty%20of%20other%20ways%20to%20ensure%20that%20Adele%20(admin)%20is%20authorized%20to%20access%20Diego%E2%80%99s%20AIP%20audit%20data%2C%20we%20opted%20for%20the%20more%20traditional%20approach%20of%20checking%20her%20group%20membership.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%E2%80%99s%20begin%20by%20getting%20an%20AccessToken%20that%20we%E2%80%99ll%20use%20to%20call%20the%20Microsoft%20Graph.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135746i2F87B9D2D5C0250E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Pic1.png%22%20title%3D%22Pic1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EHere%20we%20save%20the%20user%20and%20admin%E2%80%99s%20email%20addresses%20into%20separate%20variables%20and%20obtain%20an%20AccessToken.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135747i9E730ED4F52CF868%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Pic2.png%22%20title%3D%22Pic2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWe%20then%20make%20the%20following%20calls%20to%20the%20Microsoft%20Graph%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EGet%20the%20user%E2%80%99s%20country%3C%2FLI%3E%0A%3CLI%3ECheck%20group%20membership%20for%20the%20administrator%3C%2FLI%3E%0A%3CLI%3EGet%20the%20administrator%E2%80%99s%20country%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135748i08A51DEC109EF7CD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Pic3.png%22%20title%3D%22Pic3.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20example%2C%20we%20created%20a%20security%20group%20for%20all%20compliance%20administrators%20in%20Germany%20and%20added%20Adele%20as%20its%20only%20member.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135749i2C7832056445D702%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Pic4.png%22%20title%3D%22Pic4.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EIMPORTANT%3A%3C%2FSTRONG%3E%20For%20a%20production%20solution%2C%20you%20would%20need%20to%20make%20sure%20you%20handle%20situations%20where%20the%20country%20field%20is%20not%20populated.%20You%20may%20also%20want%20to%20consider%20comparing%20against%20a%20list%20of%20countries%20or%20regions.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20that%20we%E2%80%99ve%20made%20sure%20that%20%3CSTRONG%3EAdele%20is%20a%20member%20of%20the%20right%20group%3C%2FSTRONG%3E%20and%20%3CSTRONG%3Eis%20in%20the%20same%20country%20as%20the%20user%3C%2FSTRONG%3E%2C%20we%20proceed%20to%20query%20Log%20Analytics%20for%20the%20user%E2%80%99s%20AIP%20activity.%20If%20either%20of%20the%20above%20requirements%20are%20not%20met%2C%20return%20a%20custom%20message%20to%20compliance%20professional.%20A%20recommended%20enhancement%20to%20this%20flow%20is%20to%20notify%20other%20administrators%20if%20there%E2%80%99s%20a%20failed%20attempt%20due%20to%20insufficient%20access.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135750iE8226FA63F16A697%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Pic5.png%22%20title%3D%22Pic5.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20code%20below%20is%20used%20to%20query%20the%20Microsoft%20Graph%20and%20confirm%20that%20the%20administrator%20is%20member%20of%20the%20desired%20group%20by%20using%20its%20object%20ID%20from%20Azure%20AD.%20For%20a%20production%20grade%20application%20you%20would%20need%20to%20implement%20additional%20logic%20to%20determine%20admin%20access%20to%20user%E2%80%99s%20data.%20Additionally%2C%20you%20may%20want%20to%20verify%20the%20admin%E2%80%99s%20group%20membership%20and%20office%20location%20from%20a%20fronted%20web%20or%20mobile%20application.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135752i226ED639C6AEBB6D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Pic6.png%22%20title%3D%22Pic6.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EIMPORTANT%3A%3C%2FSTRONG%3E%20This%20step%20is%20using%20the%20contact%20information%20in%20the%20Microsoft%20Graph.%20However%2C%20you%20can%20call%20any%20other%20system%20(ERP%2C%20etc.)%20to%20obtain%20this%20data.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135753iB9CC3415D20E4676%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Pic7.png%22%20title%3D%22Pic7.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThis%20code%20takes%20a%20user%E2%80%99s%20email%20and%20a%20Graph%20access%20token%20to%20query%20the%20Microsoft%20Graph%20and%20retrieve%20the%20user%E2%80%99s%20country%20property.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135754i8C48CA6920C1A42D%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22pic8.png%22%20title%3D%22pic8.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20everything%20checks%20out%2C%20we%20pass%20the%20user%E2%80%99s%20email%20address%20to%20the%20below%20code%20and%20retrieve%20the%20desired%20AIP%20activity.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135755i22DACC7132C4207C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22pic9.png%22%20title%3D%22pic9.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EYou%20now%20have%20an%20Azure%20Function%20configured%20and%20ready%20for%20testing.%20Follow%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-functions%2Ffunctions-create-your-first-function-visual-studio%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%20link%3C%2FA%3E%20to%20publish%20your%20Function%20to%20Azure%20from%20Visual%20Studio.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20let%E2%80%99s%20test%20your%20solution.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20change%20things%20a%20bit%2C%20we%20are%20going%20to%20provide%20a%20way%20to%20test%20your%20Function%20via%20PowerShell.%20First%2C%20get%20your%20Function%E2%80%99s%20URL%20and%20default%20Key%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENavigate%20to%20your%20Function%20in%20the%20Azure%20Portal%20and%20click%20on%20the%20Function%20name%20(Function1%20in%20this%20case).%20You%20then%20click%20on%20the%20%3CSTRONG%3E%20Get%20function%20URL%3C%2FSTRONG%3E%20link%20as%20shown%20below.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20826px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135756i196BD21187AD2146%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22pic10.png%22%20title%3D%22pic10.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20the%20pop-up%20screen%2C%20copy%20the%20URL%20value%20into%20Notepad%20or%20your%20application%20of%20choice.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20829px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135757iFF203BB727219768%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22pic11.png%22%20title%3D%22pic11.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFinally%2C%20let%E2%80%99s%20run%20some%20PowerShell.%26nbsp%3BPopulate%20the%20following%20values%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSTRONG%3E%24AzSubscriptionId%3C%2FSTRONG%3E%20%E2%80%93%20Your%20Azure%20Subscription%20ID%20where%20the%20Function%20and%20Log%20Analytics%20are%20hosted%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%24userId%3C%2FSTRONG%3E%20%E2%80%93%20The%20email%20for%20the%20user%20whose%20AIP%20activity%20you%20want%20to%20search%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%24AppName%20%3C%2FSTRONG%3E%E2%80%93%20The%20name%20of%20the%20application%20created%20when%20you%20published%20the%20Function%20to%20Azure.%20-%20e.g.%20https%3A%2F%2F%3CSTRONG%3E%3CAPP_NAME%3E.%3C%2FAPP_NAME%3E%3C%2FSTRONG%3Enet%2F...%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%24FunctionName%3C%2FSTRONG%3E%20%E2%80%93%20%E2%80%9C%3CSTRONG%3EFunction1%3C%2FSTRONG%3E%E2%80%9D%20in%20this%20example%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%24FunctionKey%3C%2FSTRONG%3E%20%E2%80%93%20The%20key%20at%20the%20end%20of%20the%20URL%20value%20from%20the%20previous%20step%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%24adminEmail%20%3C%2FSTRONG%3E%E2%80%93%20the%20email%20address%20of%20the%20compliance%20professional%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135758iFC27EBA61E1093D2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22pic12.png%22%20title%3D%22pic12.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFrom%20the%20PowerShell%20ISE%2C%20run%20the%20code%20above.%20As%20a%20security%20or%20compliance%20professional%20(Adele%20in%20this%20case)%2C%20enter%20your%20username%20and%20password.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20314px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135759iDC5FD7A24783EAAB%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22pic13.png%22%20title%3D%22pic13.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20all%20requirements%20are%20met%20and%20we%20find%20data%20for%20the%20provided%20user%2C%20we%20return%20it%20as%20shown%20below.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135760iA4BF30979965695B%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22pic14.png%22%20title%3D%22pic14.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20one%20or%20more%20conditions%20are%20not%20met%2C%20you%20should%20see%20the%20custom%20message%20configured%20in%20the%20Function%20as%20shown%20below.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F135761i692BF49881F933FA%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22pic15.png%22%20title%3D%22pic15.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAt%20this%20point%20you%20may%20be%20asking%20what%20if%20I%20want%20to%20search%20for%20a%20document%20instead%3F%20Well%2C%20you%20can%20use%20the%20same%20app%20and%20add%20a%20few%20tweaks%20to%20it%20to%20accommodate%20a%20document%20search.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20you%20could%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EPass%20a%20document%20name%20to%20the%20Azure%20Function%3C%2FLI%3E%0A%3CLI%3EHave%20the%20Function%20query%20Log%20Analytics%20for%20the%20desired%20document%3C%2FLI%3E%0A%3CLI%3EGet%20the%20Protection%20Owner%20(user%E2%80%99s%20email%20address)%20from%20the%20AIP%20activity%20on%20the%20document%3C%2FLI%3E%0A%3CLI%3ECall%20the%20Microsoft%20Graph%20and%20get%20the%20user%E2%80%99s%20country%3C%2FLI%3E%0A%3CLI%3EFinally%2C%20modify%20the%20Kusto%20query%20to%20return%20a%20list%20of%20documents%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EFor%20now%2C%20I%20will%20leave%20that%20enhancement%20to%20your%20very%20capable%20hands.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20you%E2%80%99ve%20seen%20above%2C%20we%20demonstrated%20how%20to%20create%20a%20custom%20solution%20for%20your%20security%20and%2For%20compliance%20administrators%20to%20quickly%20view%20AIP%20labeling%20activity%20by%20a%20user.%20We%20also%20showed%20the%20ability%20to%20restrict%20access%20to%20AIP%20audit%20data%20to%20the%20right%20administrators%20and%20only%20within%20the%20desired%20country%20or%20region.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAlthough%20we%20used%20PowerShell%20as%20the%20frontend%20today%2C%20you%20can%20of%20course%20create%20a%20web%20app%20to%20call%20the%20Azure%20Functions%20API.%20You%20should%20be%20able%20to%20reuse%20the%20portal%20created%20on%20our%20previous%20post%20and%20you%20can%20find%20the%20sample%20code%20in%20this%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure-Samples%2FAIP-Custom-Tracking-Portal-Samples%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Erepo%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20source%20code%20for%20this%20Function%20can%20be%20found%20in%20this%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fazure-samples%2FAIP-Graph-Function-For-Admins%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EGitHub%20repo%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20stay%20tuned%20for%20our%20third%20and%20last%20installment%20of%20this%20series%20where%20we%20will%20show%20you%20how%20to%20notify%20users%20and%2For%20admins%20when%20an%20AIP%20Access%20Denied%20event%20is%20received%20in%20your%20Log%20Analytics%20Workspace.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%20for%20reading%20and%20please%20keep%20your%20feedback%20coming%20via%20the%20AIP%20Yammer%20group%20using%20the%20hashtag%20%3CSTRONG%3E%23AIPLogsSolution%3C%2FSTRONG%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-898424%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20you%20ever%20wanted%20to%20restrict%20access%20for%20your%20security%20and%2For%20compliance%20administrators%20to%20AIP%20logs%20just%20within%20their%20own%20country%20or%20region%2C%20we've%20put%20together%20a%20sample%20custom%20solution%20that%20may%20help%20grant%20that%20wish.%3C%2FP%3E%3C%2FLINGO-TEASER%3E

In the first installment of this 3-part blog series, we showed you how to create a custom AIP tracking portal that allowed end users to see access activity for their protected documents.

 

Today’s blog will focus on how you can empower your security and/or compliance professionals to access AIP labeling activity by other users within your organization. But, with an added bonus. The sample solution demonstrates how you could ensure that only the right administrators have access to user’s labeling data and within the right country or region.

 

For today’s scenario, we will introduce you to three personas within the Contoso organization.

 

First, a bit of context about the company: Contoso is a multinational organization with offices across Europe and the United States. Due to GDPR as well as internal regulations, Contoso needs to make sure that compliance administrators are not able to see AIP labeling data for users outside their own country or region.

 

And now let’s meet the personas involved.

  • Persona 1: Alex Wilber – Alex is a Contoso employee who works out of the Munich office in Germany
  • Persona 2: Diego Siciliani – Diego is a Contoso employee who works out of the Bellevue office in the United States
  • Persona 3: Adele Vance – Adele is a Compliance professional at Contoso who works out of the New York office in the United States

As you’re probably aware by now, AIP stores all labeling activity in a single Log Analytics Workspace within a selected region. Although there we provide ways to restrict access to this data via RBAC, it’s an all or nothing proposition. If you grant an administrator reader’s access to the logs, that administrator will be able to see all logs by all users despite the user’s location.  Log Analytics API however, gives you more control on what data you present to a security or compliance professional as you’ll see below.

 

Let’s look at the requirements. This solution is very similar to what we used on the previous user portal so please refer to our first blog for more details.

 

At a high level however, you need:

  1. An application registered within Azure AD (service principal)
    1. The service principal needs access to the Microsoft Graph
  2. Azure Function
  3. Log Analytics Workspace
  4. PowerShell to test the solution

Let’s look at some snippets of the code we used.

 

Like the previous user portal solution, we are leveraging an Azure Function but in this case there a couple of new features you would want to pay attention to. In this example, Adele Vance (compliance professional) wants to get a list of AIP files that were protected by Diego (end user).  

 

To comply with Contoso’s policy, we need to make sure that Adele is authorized to access Diego’s AIP labeling activity. To that end, the Function expects to receive the email address for both Adele (admin) and Diego (user). Once the Function receives those two values, it calls the Microsoft Graph to 1) verify Adele’s rights by checking her group membership and to ensure both users are located within the same country.

 

IMPORTANT: While there are plenty of other ways to ensure that Adele (admin) is authorized to access Diego’s AIP audit data, we opted for the more traditional approach of checking her group membership.

 

Let’s begin by getting an AccessToken that we’ll use to call the Microsoft Graph.

Pic1.pngGraph API app builder

Here we save the user and admin’s email addresses into separate variables and obtain an AccessToken.

Pic2.pngGetting an access token from the Graph API

We then make the following calls to the Microsoft Graph:

  1. Get the user’s country
  2. Check group membership for the administrator
  3. Get the administrator’s country

Pic3.pngCall the Graph API to get user information

 

In this example, we created a security group for all compliance administrators in Germany and added Adele as its only member.

Pic4.pngAAD Security Group

 

IMPORTANT: For a production solution, you would need to make sure you handle situations where the country field is not populated. You may also want to consider comparing against a list of countries or regions.

 

Now that we’ve made sure that Adele is a member of the right group and is in the same country as the user, we proceed to query Log Analytics for the user’s AIP activity. If either of the above requirements are not met, return a custom message to compliance professional. A recommended enhancement to this flow is to notify other administrators if there’s a failed attempt due to insufficient access.

Pic5.pngCheck admin authorization

 

The code below is used to query the Microsoft Graph and confirm that the administrator is member of the desired group by using its object ID from Azure AD. For a production grade application you would need to implement additional logic to determine admin access to user’s data. Additionally, you may want to verify the admin’s group membership and office location from a fronted web or mobile application.

Pic6.pngAdmin authorization function

IMPORTANT: This step is using the contact information in the Microsoft Graph. However, you can call any other system (ERP, etc.) to obtain this data.

Pic7.pngContact information view

This code takes a user’s email and a Graph access token to query the Microsoft Graph and retrieve the user’s country property.

pic8.pngGet user country from Graph API

 

Once everything checks out, we pass the user’s email address to the below code and retrieve the desired AIP activity.

pic9.pngRun query against Log Analytics

You now have an Azure Function configured and ready for testing. Follow this link to publish your Function to Azure from Visual Studio.

 

Now let’s test your solution.

 

To change things a bit, we are going to provide a way to test your Function via PowerShell. First, get your Function’s URL and default Key:

 

Navigate to your Function in the Azure Portal and click on the Function name (Function1 in this case). You then click on the </> Get function URL link as shown below.

pic10.pngGet Function URL

 

From the pop-up screen, copy the URL value into Notepad or your application of choice.

pic11.pngCopy Function URL

 

Finally, let’s run some PowerShell. Populate the following values:

  1. $AzSubscriptionId – Your Azure Subscription ID where the Function and Log Analytics are hosted
  2. $userId – The email for the user whose AIP activity you want to search
  3. $AppName – The name of the application created when you published the Function to Azure. - e.g. https://<APP_NAME>.net/...
  4. $FunctionName – “Function1” in this example
  5. $FunctionKey – The key at the end of the URL value from the previous step
  6. $adminEmail – the email address of the compliance professional

pic12.pngPowerShell code

 

From the PowerShell ISE, run the code above. As a security or compliance professional (Adele in this case), enter your username and password.

pic13.pngAzure Sign In screen

 

If all requirements are met and we find data for the provided user, we return it as shown below.

pic14.pngPowerShell results screen

 

If one or more conditions are not met, you should see the custom message configured in the Function as shown below.

pic15.png

 

At this point you may be asking what if I want to search for a document instead? Well, you can use the same app and add a few tweaks to it to accommodate a document search.

 

For example, you could:

  1. Pass a document name to the Azure Function
  2. Have the Function query Log Analytics for the desired document
  3. Get the Protection Owner (user’s email address) from the AIP activity on the document
  4. Call the Microsoft Graph and get the user’s country
  5. Finally, modify the Kusto query to return a list of documents

For now, I will leave that enhancement to your very capable hands.

 

As you’ve seen above, we demonstrated how to create a custom solution for your security and/or compliance administrators to quickly view AIP labeling activity by a user. We also showed the ability to restrict access to AIP audit data to the right administrators and only within the desired country or region.

 

Although we used PowerShell as the frontend today, you can of course create a web app to call the Azure Functions API. You should be able to reuse the portal created on our previous post and you can find the sample code in this repo.

 

The source code for this Function can be found in this GitHub repo.

 

Please stay tuned for our third and last installment of this series where we will show you how to notify users and/or admins when an AIP Access Denied event is received in your Log Analytics Workspace.

 

Thanks for reading and please keep your feedback coming via the AIP Yammer group using the hashtag #AIPLogsSolution.