├── MAUI
└── README.md
├── 1-Basic
├── ReadmeFiles
│ └── Topology.png
├── UserDetailsClient
│ ├── UserDetailsClient.iOS
│ │ ├── iTunesArtwork
│ │ ├── iTunesArtwork@2x
│ │ ├── Resources
│ │ │ ├── Default.png
│ │ │ ├── Icon-76.png
│ │ │ ├── Default@2x.png
│ │ │ ├── Icon-60@2x.png
│ │ │ ├── Icon-60@3x.png
│ │ │ ├── Icon-76@2x.png
│ │ │ ├── Icon-Small.png
│ │ │ ├── Default-568h@2x.png
│ │ │ ├── Icon-Small-40.png
│ │ │ ├── Icon-Small@2x.png
│ │ │ ├── Icon-Small@3x.png
│ │ │ ├── Default-Portrait.png
│ │ │ ├── Icon-Small-40@2x.png
│ │ │ ├── Icon-Small-40@3x.png
│ │ │ ├── Default-Portrait@2x.png
│ │ │ └── LaunchScreen.storyboard
│ │ ├── Entitlements.plist
│ │ ├── Main.cs
│ │ ├── MainPageRenderer.cs
│ │ ├── AppDelegate.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── Info.plist
│ ├── UserDetailsClient.UWP
│ │ ├── Assets
│ │ │ ├── StoreLogo.png
│ │ │ ├── SplashScreen.scale-200.png
│ │ │ ├── LockScreenLogo.scale-200.png
│ │ │ ├── Square44x44Logo.scale-200.png
│ │ │ ├── Wide310x150Logo.scale-200.png
│ │ │ ├── Square150x150Logo.scale-200.png
│ │ │ └── Square44x44Logo.targetsize-24_altform-unplated.png
│ │ ├── App.xaml
│ │ ├── MainPage.xaml
│ │ ├── Properties
│ │ │ ├── AssemblyInfo.cs
│ │ │ └── Default.rd.xml
│ │ ├── MainPage.xaml.cs
│ │ ├── Package.appxmanifest
│ │ └── App.xaml.cs
│ ├── UserDetailsClient
│ │ ├── GettingStarted.Xamarin
│ │ ├── GlobalSuppressions.cs
│ │ ├── UserDetailsClient.csproj
│ │ ├── App.cs
│ │ ├── MainPage.xaml
│ │ └── MainPage.xaml.cs
│ └── UserDetailsClient.Droid
│ │ ├── Resources
│ │ ├── drawable
│ │ │ └── icon.png
│ │ ├── drawable-hdpi
│ │ │ └── icon.png
│ │ ├── drawable-xhdpi
│ │ │ └── icon.png
│ │ ├── drawable-xxhdpi
│ │ │ └── icon.png
│ │ └── AboutResources.txt
│ │ ├── Assets
│ │ └── AboutAssets.txt
│ │ ├── MsalActivity.cs
│ │ ├── MainPageRenderer.cs
│ │ ├── MainActivity.cs
│ │ └── Properties
│ │ ├── AssemblyInfo.cs
│ │ └── AndroidManifest.xml
└── AppCreationScripts
│ ├── Cleanup.ps1
│ └── sample.json
├── 2-With-broker
├── ReadmeFiles
│ └── Topology.png
├── UserDetailsClient
│ ├── UserDetailsClient.iOS
│ │ ├── iTunesArtwork
│ │ ├── iTunesArtwork@2x
│ │ ├── Resources
│ │ │ ├── Default.png
│ │ │ ├── Icon-76.png
│ │ │ ├── Default@2x.png
│ │ │ ├── Icon-60@2x.png
│ │ │ ├── Icon-60@3x.png
│ │ │ ├── Icon-76@2x.png
│ │ │ ├── Icon-Small.png
│ │ │ ├── Icon-Small-40.png
│ │ │ ├── Icon-Small@2x.png
│ │ │ ├── Icon-Small@3x.png
│ │ │ ├── Default-568h@2x.png
│ │ │ ├── Default-Portrait.png
│ │ │ ├── Icon-Small-40@2x.png
│ │ │ ├── Icon-Small-40@3x.png
│ │ │ ├── Default-Portrait@2x.png
│ │ │ └── LaunchScreen.storyboard
│ │ ├── Entitlements.plist
│ │ ├── Main.cs
│ │ ├── MainPageRenderer.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── AppDelegate.cs
│ │ └── Info.plist
│ ├── UserDetailsClient.UWP
│ │ ├── Assets
│ │ │ ├── StoreLogo.png
│ │ │ ├── SplashScreen.scale-200.png
│ │ │ ├── LockScreenLogo.scale-200.png
│ │ │ ├── Square150x150Logo.scale-200.png
│ │ │ ├── Square44x44Logo.scale-200.png
│ │ │ ├── Wide310x150Logo.scale-200.png
│ │ │ └── Square44x44Logo.targetsize-24_altform-unplated.png
│ │ ├── App.xaml
│ │ ├── MainPage.xaml
│ │ ├── Properties
│ │ │ ├── AssemblyInfo.cs
│ │ │ └── Default.rd.xml
│ │ ├── MainPage.xaml.cs
│ │ ├── Package.appxmanifest
│ │ └── App.xaml.cs
│ ├── UserDetailsClient
│ │ ├── GettingStarted.Xamarin
│ │ ├── GlobalSuppressions.cs
│ │ ├── UserDetailsClient.csproj
│ │ ├── App.cs
│ │ └── MainPage.xaml
│ └── UserDetailsClient.Droid
│ │ ├── Resources
│ │ ├── drawable
│ │ │ └── icon.png
│ │ ├── drawable-hdpi
│ │ │ └── icon.png
│ │ ├── drawable-xhdpi
│ │ │ └── icon.png
│ │ ├── drawable-xxhdpi
│ │ │ └── icon.png
│ │ └── AboutResources.txt
│ │ ├── MsalActivity.cs
│ │ ├── Assets
│ │ └── AboutAssets.txt
│ │ ├── MainPageRenderer.cs
│ │ ├── MainActivity.cs
│ │ └── Properties
│ │ ├── AssemblyInfo.cs
│ │ └── AndroidManifest.xml
├── AppCreationScripts
│ ├── Cleanup.ps1
│ └── sample.json
└── .gitignore
├── 3-With-Intune MAM
├── IntuneClient
│ ├── active-directory-xamarin-intune
│ │ ├── AssemblyInfo.cs
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── active-directory-xamarin-intune.csproj
│ │ ├── MainPage.xaml
│ │ ├── IIntuneMAMConnector.cs
│ │ ├── PlatformConfigImpl.cs
│ │ ├── PCAWrapper.cs
│ │ └── MainPage.xaml.cs
│ ├── active-directory-xamarin-intune.iOS
│ │ ├── Resources
│ │ │ ├── Default.png
│ │ │ ├── Default@2x.png
│ │ │ ├── Default-568h@2x.png
│ │ │ ├── Default-Portrait.png
│ │ │ ├── Default-Portrait@2x.png
│ │ │ └── LaunchScreen.storyboard
│ │ ├── Assets.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ │ ├── Icon20.png
│ │ │ │ ├── Icon29.png
│ │ │ │ ├── Icon40.png
│ │ │ │ ├── Icon58.png
│ │ │ │ ├── Icon60.png
│ │ │ │ ├── Icon76.png
│ │ │ │ ├── Icon80.png
│ │ │ │ ├── Icon87.png
│ │ │ │ ├── Icon1024.png
│ │ │ │ ├── Icon120.png
│ │ │ │ ├── Icon152.png
│ │ │ │ ├── Icon167.png
│ │ │ │ ├── Icon180.png
│ │ │ │ └── Contents.json
│ │ ├── Entitlements.plist
│ │ ├── Main.cs
│ │ ├── MainIntuneMAMEnrollmentDelegate.cs
│ │ ├── MainIntuneMAMComplianceDelegate.cs
│ │ ├── IntuneMAMConnector.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── AppDelegate.cs
│ │ ├── Info.plist
│ │ └── active-directory-xamarin-intune.iOS.csproj
│ └── active-directory-xamarin-intune.Android
│ │ ├── Resources
│ │ ├── mipmap-hdpi
│ │ │ ├── icon.png
│ │ │ └── launcher_foreground.png
│ │ ├── mipmap-mdpi
│ │ │ ├── icon.png
│ │ │ └── launcher_foreground.png
│ │ ├── mipmap-xhdpi
│ │ │ ├── icon.png
│ │ │ └── launcher_foreground.png
│ │ ├── mipmap-xxhdpi
│ │ │ ├── icon.png
│ │ │ └── launcher_foreground.png
│ │ ├── mipmap-xxxhdpi
│ │ │ ├── icon.png
│ │ │ └── launcher_foreground.png
│ │ ├── values
│ │ │ ├── colors.xml
│ │ │ └── styles.xml
│ │ ├── mipmap-anydpi-v26
│ │ │ ├── icon.xml
│ │ │ └── icon_round.xml
│ │ └── AboutResources.txt
│ │ ├── Assets
│ │ └── AboutAssets.txt
│ │ ├── Properties
│ │ ├── AndroidManifest.xml
│ │ └── AssemblyInfo.cs
│ │ ├── MAMWEAuthCallback.cs
│ │ ├── IntuneSampleApp.cs
│ │ ├── IntuneMAMConnector.cs
│ │ ├── MainActivity.cs
│ │ └── EnrollmentNotificationReceiver.cs
└── active-directory-xamarin-intune.sln
├── CONTRIBUTING.md
├── LICENSE
├── MauiApps.md
├── .gitignore
├── .tours
└── mam-sample-tour.tour
└── README.md
/MAUI/README.md:
--------------------------------------------------------------------------------
1 | [MAUI sample has moved](https://github.com/Azure-Samples/ms-identity-dotnetcore-maui)
2 |
3 |
--------------------------------------------------------------------------------
/1-Basic/ReadmeFiles/Topology.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/ReadmeFiles/Topology.png
--------------------------------------------------------------------------------
/2-With-broker/ReadmeFiles/Topology.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/ReadmeFiles/Topology.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using Xamarin.Forms.Xaml;
2 |
3 | [assembly: XamlCompilation(XamlCompilationOptions.Compile)]
4 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/iTunesArtwork:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/iTunesArtwork
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/iTunesArtwork@2x:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/iTunesArtwork@2x
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/iTunesArtwork:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/iTunesArtwork
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/StoreLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/StoreLogo.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Default.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-76.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient/GettingStarted.Xamarin:
--------------------------------------------------------------------------------
1 |
2 | GS\XF\CS\App\GettingStarted.html
3 | false
4 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Default@2x.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-60@2x.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-60@3x.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-76@2x.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/iTunesArtwork@2x:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/iTunesArtwork@2x
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/StoreLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/StoreLogo.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient/GettingStarted.Xamarin:
--------------------------------------------------------------------------------
1 |
2 | GS\XF\CS\App\GettingStarted.html
3 | false
4 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable/icon.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Default-568h@2x.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small-40.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small@2x.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small@3x.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Default.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-76.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Default-Portrait.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small-40@2x.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small-40@3x.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Default@2x.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-60@2x.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-60@3x.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-76@2x.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/SplashScreen.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/SplashScreen.scale-200.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small-40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small-40.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small@2x.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small@3x.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable-xhdpi/icon.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable-xxhdpi/icon.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/LockScreenLogo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/LockScreenLogo.scale-200.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/Square44x44Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/Square44x44Logo.scale-200.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/Wide310x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/Wide310x150Logo.scale-200.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable/icon.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Default-568h@2x.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Default-Portrait.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small-40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small-40@2x.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small-40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Icon-Small-40@3x.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/Square150x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/Square150x150Logo.scale-200.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/SplashScreen.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/SplashScreen.scale-200.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable-hdpi/icon.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable-xhdpi/icon.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/LockScreenLogo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/LockScreenLogo.scale-200.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Resources/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Resources/Default.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/Resources/drawable-xxhdpi/icon.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/Square150x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/Square150x150Logo.scale-200.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/Square44x44Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/Square44x44Logo.scale-200.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/Wide310x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/Wide310x150Logo.scale-200.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Resources/Default@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Resources/Default@2x.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Resources/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Resources/Default-568h@2x.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Resources/Default-Portrait.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Resources/Default-Portrait.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-hdpi/icon.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-mdpi/icon.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-xhdpi/icon.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Resources/Default-Portrait@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Resources/Default-Portrait@2x.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-xxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-xxhdpi/icon.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-xxxhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-xxxhdpi/icon.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon20.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon20.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon29.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon29.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon40.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon40.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon58.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon58.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon60.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon60.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon76.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon76.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon80.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon80.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon87.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon87.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon1024.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon120.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon120.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon152.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon152.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon167.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon167.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon180.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Icon180.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-hdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-hdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-mdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-mdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-xhdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-xhdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-xxhdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-xxhdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-xxxhdpi/launcher_foreground.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/active-directory-xamarin-native-v2/HEAD/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-xxxhdpi/launcher_foreground.png
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 | #3F51B5
5 | #303F9F
6 | #FF4081
7 |
8 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-anydpi-v26/icon.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/mipmap-anydpi-v26/icon_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/App.xaml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | keychain-access-groups
6 |
7 | $(AppIdentifierPrefix)com.microsoft.adalcache
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | keychain-access-groups
6 |
7 | $(AppIdentifierPrefix)com.microsoft.adalcache
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Main.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | using Foundation;
6 | using UIKit;
7 |
8 | namespace UserDetailsClient.iOS
9 | {
10 | public class Application
11 | {
12 | // This is the main entry point of the application.
13 | static void Main(string[] args)
14 | {
15 | // if you want to use a different Application Delegate class from "AppDelegate"
16 | // you can specify it here.
17 | UIApplication.Main(args, null, "AppDelegate");
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Main.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | using Foundation;
6 | using UIKit;
7 |
8 | namespace UserDetailsClient.iOS
9 | {
10 | public class Application
11 | {
12 | // This is the main entry point of the application.
13 | static void Main(string[] args)
14 | {
15 | // if you want to use a different Application Delegate class from "AppDelegate"
16 | // you can specify it here.
17 | UIApplication.Main(args, null, "AppDelegate");
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | keychain-access-groups
6 |
7 | $(AppIdentifierPrefix)com.yourcompany.XamarinIntuneApp
8 | $(AppIdentifierPrefix)com.microsoft.intune.mam
9 | $(AppIdentifierPrefix)com.microsoft.adalcache
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 |
2 | // This file is used by Code Analysis to maintain SuppressMessage
3 | // attributes that are applied to this project.
4 | // Project-level suppressions either have no target or are given
5 | // a specific target and scoped to a namespace, type, member, etc.
6 |
7 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("AsyncUsage.CSharp.Reliability", "AvoidAsyncVoid:Avoid async void", Justification = "(false positive): event handlers are the only async method that can return void", Scope = "member", Target = "~M:UserDetailsClient.MainPage.OnSignInSignOut(System.Object,System.EventArgs)")]
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient/GlobalSuppressions.cs:
--------------------------------------------------------------------------------
1 |
2 | // This file is used by Code Analysis to maintain SuppressMessage
3 | // attributes that are applied to this project.
4 | // Project-level suppressions either have no target or are given
5 | // a specific target and scoped to a namespace, type, member, etc.
6 |
7 | [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("AsyncUsage.CSharp.Reliability", "AvoidAsyncVoid:Avoid async void", Justification = "(false positive): event handlers are the only async method that can return void", Scope = "member", Target = "~M:UserDetailsClient.MainPage.OnSignInSignOut(System.Object,System.EventArgs)")]
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xamarin.Forms;
3 | using Xamarin.Forms.Xaml;
4 |
5 | namespace active_directory_xamarin_intune
6 | {
7 | public partial class App : Application
8 | {
9 | public App()
10 | {
11 | InitializeComponent();
12 |
13 | MainPage = new MainPage();
14 | }
15 |
16 | protected override void OnStart()
17 | {
18 | }
19 |
20 | protected override void OnSleep()
21 | {
22 | }
23 |
24 | protected override void OnResume()
25 | {
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Main.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using UIKit;
6 |
7 | namespace active_directory_xamarin_intune.iOS
8 | {
9 | public class Application
10 | {
11 | // This is the main entry point of the application.
12 | static void Main(string[] args)
13 | {
14 | // if you want to use a different Application Delegate class from "AppDelegate"
15 | // you can specify it here.
16 | UIApplication.Main(args, null, typeof(AppDelegate));
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/MainPageRenderer.cs:
--------------------------------------------------------------------------------
1 | using UserDetailsClient;
2 | using UserDetailsClient.iOS;
3 | using Xamarin.Forms;
4 | using Xamarin.Forms.Platform.iOS;
5 | [assembly: ExportRenderer(typeof(MainPage), typeof(MainPageRenderer))]
6 | namespace UserDetailsClient.iOS
7 | {
8 | class MainPageRenderer : PageRenderer
9 | {
10 | MainPage page;
11 | protected override void OnElementChanged(VisualElementChangedEventArgs e)
12 | {
13 | base.OnElementChanged(e);
14 | page = e.NewElement as MainPage;
15 | }
16 | public override void ViewDidLoad()
17 | {
18 | base.ViewDidLoad();
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.Droid/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories) and given a Build Action of "AndroidAsset".
3 |
4 | These files will be deployed with you package and will be accessible using Android's
5 | AssetManager, like this:
6 |
7 | public class ReadAsset : Activity
8 | {
9 | protected override void OnCreate (Bundle bundle)
10 | {
11 | base.OnCreate (bundle);
12 |
13 | InputStream input = Assets.Open ("my_asset.txt");
14 | }
15 | }
16 |
17 | Additionally, some Android functions will automatically load asset files:
18 |
19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
20 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/MsalActivity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using Android.App;
7 | using Android.Content;
8 | using Android.OS;
9 | using Android.Runtime;
10 | using Android.Views;
11 | using Android.Widget;
12 | using Microsoft.Identity.Client;
13 |
14 | namespace UserDetailsClient.Droid
15 | {
16 | [Activity(Exported=true)]
17 | [IntentFilter(new[] { Intent.ActionView },
18 | Categories = new[] { Intent.CategoryBrowsable, Intent.CategoryDefault },
19 | DataHost = "auth",
20 | DataScheme = "msal4a1aa1d5-c567-49d0-ad0b-cd957a47f842")]
21 | public class MsalActivity : BrowserTabActivity
22 | {
23 | }
24 | }
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories) and given a Build Action of "AndroidAsset".
3 |
4 | These files will be deployed with you package and will be accessible using Android's
5 | AssetManager, like this:
6 |
7 | public class ReadAsset : Activity
8 | {
9 | protected override void OnCreate (Bundle bundle)
10 | {
11 | base.OnCreate (bundle);
12 |
13 | InputStream input = Assets.Open ("my_asset.txt");
14 | }
15 | }
16 |
17 | Additionally, some Android functions will automatically load asset files:
18 |
19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
20 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.Droid/MsalActivity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using Android.App;
7 | using Android.Content;
8 | using Android.OS;
9 | using Android.Runtime;
10 | using Android.Views;
11 | using Android.Widget;
12 | using Microsoft.Identity.Client;
13 |
14 | namespace UserDetailsClient.Droid
15 | {
16 | [Activity(Exported =true)]
17 | [IntentFilter(new[] { Intent.ActionView },
18 | Categories = new[] { Intent.CategoryBrowsable, Intent.CategoryDefault },
19 | DataHost = "auth",
20 | DataScheme = "msal4a1aa1d5-c567-49d0-ad0b-cd957a47f842")]
21 | public class MsalActivity : BrowserTabActivity
22 | {
23 | }
24 | }
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient/UserDetailsClient.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 |
5 |
6 |
7 | pdbonly
8 | true
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/MainIntuneMAMEnrollmentDelegate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using activedirectoryxamarinintune;
3 | using Microsoft.Intune.MAM;
4 |
5 | namespace active_directory_xamarin_intune.iOS
6 | {
7 | public class MainIntuneMAMEnrollmentDelegate : IntuneMAMEnrollmentDelegate
8 | {
9 | public override async void UnenrollRequestWithStatus(IntuneMAMEnrollmentStatus status)
10 | {
11 | if(!status.DidSucceed)
12 | {
13 | Console.WriteLine("Intune Unenrollment failed with status code: " + status.StatusCode + ". Error message: " + status.ErrorString);
14 | }
15 | await PCAWrapper.Instance.SignOut().ConfigureAwait(false);
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Assets/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories) and given a Build Action of "AndroidAsset".
3 |
4 | These files will be deployed with your package and will be accessible using Android's
5 | AssetManager, like this:
6 |
7 | public class ReadAsset : Activity
8 | {
9 | protected override void OnCreate (Bundle bundle)
10 | {
11 | base.OnCreate (bundle);
12 |
13 | InputStream input = Assets.Open ("my_asset.txt");
14 | }
15 | }
16 |
17 | Additionally, some Android functions will automatically load asset files:
18 |
19 | Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf");
20 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/MainPageRenderer.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Identity.Client;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using UserDetailsClient;
6 | using UserDetailsClient.iOS;
7 | using Xamarin.Forms;
8 | using Xamarin.Forms.Platform.iOS;
9 | [assembly: ExportRenderer(typeof(MainPage), typeof(MainPageRenderer))]
10 | namespace UserDetailsClient.iOS
11 | {
12 | class MainPageRenderer : PageRenderer
13 | {
14 | MainPage page;
15 | protected override void OnElementChanged(VisualElementChangedEventArgs e)
16 | {
17 | base.OnElementChanged(e);
18 | page = e.NewElement as MainPage;
19 | }
20 | public override void ViewDidLoad()
21 | {
22 | base.ViewDidLoad();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient/UserDetailsClient.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.0
4 |
5 |
6 |
7 | pdbonly
8 | true
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/active-directory-xamarin-intune.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 | true
6 |
7 |
8 |
9 | portable
10 | true
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
15 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to Azure samples
2 |
3 | Thank you for your interest in contributing to Azure samples!
4 |
5 | ## Ways to contribute
6 |
7 | You can contribute to [Azure samples](https://azure.microsoft.com/documentation/samples/) in a few different ways:
8 |
9 | - Submit feedback on [this sample page](https://azure.microsoft.com/documentation/samples/active-directory-xamarin-native-v2/) whether it was helpful or not.
10 | - Submit issues through [issue tracker](https://github.com/Azure-Samples/active-directory-xamarin-native-v2/issues) on GitHub. We are actively monitoring the issues and improving our samples.
11 | - If you wish to make code changes to samples, or contribute something new, please follow the [GitHub Forks / Pull requests model](https://help.github.com/articles/fork-a-repo/): Fork the sample repo, make the change and propose it back by submitting a pull request.
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/IIntuneMAMConnector.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Threading.Tasks;
6 | using Microsoft.Identity.Client;
7 |
8 | namespace activedirectoryxamarinintune
9 | {
10 | ///
11 | /// Interface for platform specific Intune implementation
12 | ///
13 | public interface IIntuneMAMConnector
14 | {
15 | ///
16 | /// Perform registration with MAM
17 | ///
18 | ///
19 | ///
20 | Task DoMAMRegisterAsync(IntuneAppProtectionPolicyRequiredException exProtection);
21 |
22 | ///
23 | /// Unenrolls App from MAM
24 | ///
25 | void Unenroll();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/PlatformConfigImpl.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 |
6 | namespace activedirectoryxamarinintune
7 | {
8 | ///
9 | /// Platform specific configuration.
10 | ///
11 | public class PlatformConfigImpl
12 | {
13 | ///
14 | /// Instance to store data
15 | ///
16 | public static PlatformConfigImpl Instance { get; } = new PlatformConfigImpl();
17 |
18 | ///
19 | /// Platform specific Redirect URI
20 | ///
21 | public string RedirectUri { get; set; }
22 |
23 | ///
24 | /// Platform specific parent window
25 | ///
26 | public object ParentWindow { get; set; }
27 |
28 | // private constructor to ensure singleton
29 | private PlatformConfigImpl()
30 | {
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.Droid/MainPageRenderer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using Android.App;
7 | using Android.Content;
8 | using Android.OS;
9 | using Android.Runtime;
10 | using Android.Views;
11 | using Android.Widget;
12 | using Microsoft.Identity.Client;
13 | using Xamarin.Forms.Platform.Android;
14 | using UserDetailsClient;
15 | using Xamarin.Forms;
16 | using UserDetailsClient.Droid;
17 |
18 | [assembly: ExportRenderer(typeof(MainPage), typeof(MainPageRenderer))]
19 | namespace UserDetailsClient.Droid
20 | {
21 | class MainPageRenderer : PageRenderer
22 | {
23 | public MainPageRenderer(Context context) : base(context)
24 | {
25 |
26 | }
27 | MainPage page;
28 |
29 | protected override void OnElementChanged(ElementChangedEventArgs e)
30 | {
31 | base.OnElementChanged(e);
32 | page = e.NewElement as MainPage;
33 | var activity = this.Context as Activity;
34 | }
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/MainPageRenderer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | using Android.App;
7 | using Android.Content;
8 | using Android.OS;
9 | using Android.Runtime;
10 | using Android.Views;
11 | using Android.Widget;
12 | using Microsoft.Identity.Client;
13 | using Xamarin.Forms.Platform.Android;
14 | using UserDetailsClient;
15 | using Xamarin.Forms;
16 | using UserDetailsClient.Droid;
17 |
18 | [assembly: ExportRenderer(typeof(MainPage), typeof(MainPageRenderer))]
19 | namespace UserDetailsClient.Droid
20 | {
21 | class MainPageRenderer : PageRenderer
22 | {
23 | public MainPageRenderer(Context context) : base(context)
24 | {
25 |
26 | }
27 | MainPage page;
28 |
29 | protected override void OnElementChanged(ElementChangedEventArgs e)
30 | {
31 | base.OnElementChanged(e);
32 | page = e.NewElement as MainPage;
33 | var activity = this.Context as Activity;
34 | }
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Properties/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Microsoft Corporation
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("UserDetailsClient.UWP")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("UserDetailsClient.UWP")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Version information for an assembly consists of the following four values:
18 | //
19 | // Major Version
20 | // Minor Version
21 | // Build Number
22 | // Revision
23 | //
24 | // You can specify all the values or you can default the Build and Revision Numbers
25 | // by using the '*' as shown below:
26 | // [assembly: AssemblyVersion("1.0.*")]
27 | [assembly: AssemblyVersion("1.0.0.0")]
28 | [assembly: AssemblyFileVersion("1.0.0.0")]
29 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("UserDetailsClient.UWP")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("UserDetailsClient.UWP")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Version information for an assembly consists of the following four values:
18 | //
19 | // Major Version
20 | // Minor Version
21 | // Build Number
22 | // Revision
23 | //
24 | // You can specify all the values or you can default the Build and Revision Numbers
25 | // by using the '*' as shown below:
26 | // [assembly: AssemblyVersion("1.0.*")]
27 | [assembly: AssemblyVersion("1.0.0.0")]
28 | [assembly: AssemblyFileVersion("1.0.0.0")]
29 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.Foundation;
7 | using Windows.Foundation.Collections;
8 | using Windows.UI.Xaml;
9 | using Windows.UI.Xaml.Controls;
10 | using Windows.UI.Xaml.Controls.Primitives;
11 | using Windows.UI.Xaml.Data;
12 | using Windows.UI.Xaml.Input;
13 | using Windows.UI.Xaml.Media;
14 | using Windows.UI.Xaml.Navigation;
15 |
16 | namespace UserDetailsClient.UWP
17 | {
18 | public sealed partial class MainPage
19 | {
20 | public MainPage()
21 | {
22 | this.InitializeComponent();
23 |
24 | // To have WAM working you need to register the following redirect URI for your application
25 | string sid = Windows.Security.Authentication.Web.WebAuthenticationBroker.GetCurrentApplicationCallbackUri()
26 | .Host
27 | .ToUpper();
28 | string redirectUriWithWAM = $"ms-appx-web://microsoft.aad.brokerplugin/{sid}";
29 |
30 | // Then use the following:
31 | LoadApplication(new UserDetailsClient.App());
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.Droid/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Android.App;
4 | using Android.Content.PM;
5 | using Android.Runtime;
6 | using Android.Views;
7 | using Android.Widget;
8 | using Android.OS;
9 | using Microsoft.Identity.Client;
10 | using Android.Content;
11 | using Microsoft.Identity.Client.Platforms.Android;
12 |
13 | namespace UserDetailsClient.Droid
14 | {
15 | [Activity(Label = "UserDetailsClient", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
16 | public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
17 | {
18 | protected override void OnCreate(Bundle bundle)
19 | {
20 | base.OnCreate(bundle);
21 |
22 | global::Xamarin.Forms.Forms.Init(this, bundle);
23 | LoadApplication(new App());
24 | App.ParentWindow = this;
25 | }
26 |
27 | protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
28 | {
29 | base.OnActivityResult(requestCode, resultCode, data);
30 | AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
31 | }
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using Android.App;
4 | using Android.Content.PM;
5 | using Android.Runtime;
6 | using Android.Views;
7 | using Android.Widget;
8 | using Android.OS;
9 | using Microsoft.Identity.Client;
10 | using Android.Content;
11 | using Microsoft.Identity.Client.Platforms.Android;
12 |
13 | namespace UserDetailsClient.Droid
14 | {
15 | [Activity(Label = "UserDetailsClient", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
16 | public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
17 | {
18 | protected override void OnCreate(Bundle bundle)
19 | {
20 | base.OnCreate(bundle);
21 |
22 | global::Xamarin.Forms.Forms.Init(this, bundle);
23 | LoadApplication(new App());
24 | App.ParentWindow = this;
25 | }
26 |
27 | protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
28 | {
29 | base.OnActivityResult(requestCode, resultCode, data);
30 | AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
31 | }
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using Android.App;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("active_directory_xamarin_intune.Android")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("active_directory_xamarin_intune.Android")]
14 | [assembly: AssemblyCopyright("Copyright © 2014")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: ComVisible(false)]
18 |
19 | // Version information for an assembly consists of the following four values:
20 | //
21 | // Major Version
22 | // Minor Version
23 | // Build Number
24 | // Revision
25 | [assembly: AssemblyVersion("1.0.0.0")]
26 | [assembly: AssemblyFileVersion("1.0.0.0")]
27 |
28 | // Add some common permissions, these can be removed if not needed
29 | [assembly: UsesPermission(Android.Manifest.Permission.Internet)]
30 | [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
31 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Properties/Default.rd.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Properties/Default.rd.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.Droid/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using Android.App;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("UserDetailsClient.Droid")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("UserDetailsClient.Droid")]
14 | [assembly: AssemblyCopyright("Copyright © 2014")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: ComVisible(false)]
18 |
19 | // Version information for an assembly consists of the following four values:
20 | //
21 | // Major Version
22 | // Minor Version
23 | // Build Number
24 | // Revision
25 | //
26 | // You can specify all the values or you can default the Build and Revision Numbers
27 | // by using the '*' as shown below:
28 | // [assembly: AssemblyVersion("1.0.*")]
29 | [assembly: AssemblyVersion("1.0.0.0")]
30 | [assembly: AssemblyFileVersion("1.0.0.0")]
31 |
32 | // Add some common permissions, these can be removed if not needed
33 | [assembly: UsesPermission(Android.Manifest.Permission.Internet)]
34 | [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
35 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using Android.App;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("UserDetailsClient.Droid")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("UserDetailsClient.Droid")]
14 | [assembly: AssemblyCopyright("Copyright © 2014")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 | [assembly: ComVisible(false)]
18 |
19 | // Version information for an assembly consists of the following four values:
20 | //
21 | // Major Version
22 | // Minor Version
23 | // Build Number
24 | // Revision
25 | //
26 | // You can specify all the values or you can default the Build and Revision Numbers
27 | // by using the '*' as shown below:
28 | // [assembly: AssemblyVersion("1.0.*")]
29 | [assembly: AssemblyVersion("1.0.0.0")]
30 | [assembly: AssemblyFileVersion("1.0.0.0")]
31 |
32 | // Add some common permissions, these can be removed if not needed
33 | [assembly: UsesPermission(Android.Manifest.Permission.Internet)]
34 | [assembly: UsesPermission(Android.Manifest.Permission.WriteExternalStorage)]
35 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/MainIntuneMAMComplianceDelegate.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using activedirectoryxamarinintune;
6 | using Microsoft.Intune.MAM;
7 |
8 | namespace active_directory_xamarin_intune.iOS
9 | {
10 | ///
11 | /// When device becomes Intune MAM compliant, IdentityHasComplianceStatus method in this class will be called.
12 | /// It will set the event that will let the calling app know that the device is now compliant.
13 | /// And app can take the further actions such as calling silent token acquisition.
14 | ///
15 | public class MainIntuneMAMComplianceDelegate : IntuneMAMComplianceDelegate
16 | {
17 | public override void IdentityHasComplianceStatus(string identity, IntuneMAMComplianceStatus status, string errorMessage, string errorTitle)
18 | {
19 | if (status == IntuneMAMComplianceStatus.Compliant)
20 | {
21 | try
22 | {
23 | // Now the app is compliant, set the event. It will notify the App to take the next steps.
24 | PCAWrapper.MAMRegsiteredEvent.Set();
25 | }
26 | catch (Exception ex)
27 | {
28 | System.Diagnostics.Debug.WriteLine($"Ex = {ex.Message}");
29 | }
30 |
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/IntuneMAMConnector.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Threading.Tasks;
6 | using activedirectoryxamarinintune;
7 | using Microsoft.Identity.Client;
8 | using Microsoft.Intune.MAM;
9 |
10 | namespace active_directory_xamarin_intune.iOS
11 | {
12 | public class IntuneMAMConnector : IIntuneMAMConnector
13 | {
14 | public async Task DoMAMRegisterAsync(IntuneAppProtectionPolicyRequiredException exProtection)
15 | {
16 | // Reset the registration event. So the app will wait till it is complete.
17 | PCAWrapper.MAMRegsiteredEvent.Reset();
18 | // Using IntuneMAMComplianceManager, ensure that the device is compliant.
19 | // This will raise UI for compliance. After user satisfies the compliance requirements, MainIntuneMAMComplianceDelegate method will be called.
20 | // the delegate will set the semaphore
21 | IntuneMAMComplianceManager.Instance.RemediateComplianceForIdentity(exProtection.Upn, false);
22 |
23 | // Wait for the delegate to signal that it is compliant
24 | PCAWrapper.MAMRegsiteredEvent.WaitOne();
25 | }
26 |
27 | public void Unenroll()
28 | {
29 | IntuneMAMEnrollmentManager.Instance.DeRegisterAndUnenrollAccount(IntuneMAMEnrollmentManager.Instance.EnrolledAccount, true);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.Foundation;
7 | using Windows.Foundation.Collections;
8 | using Windows.UI.Xaml;
9 | using Windows.UI.Xaml.Controls;
10 | using Windows.UI.Xaml.Controls.Primitives;
11 | using Windows.UI.Xaml.Data;
12 | using Windows.UI.Xaml.Input;
13 | using Windows.UI.Xaml.Media;
14 | using Windows.UI.Xaml.Navigation;
15 |
16 | namespace UserDetailsClient.UWP
17 | {
18 | public sealed partial class MainPage
19 | {
20 | public MainPage()
21 | {
22 | this.InitializeComponent();
23 |
24 | // To get SSO with a UWP app, you'll need to register the following
25 | // redirect URI for your application
26 | Uri redirectURIForSsoWithoutBroker = Windows.Security.Authentication.Web.WebAuthenticationBroker.GetCurrentApplicationCallbackUri();
27 |
28 | // To have WAM working you need to register the following redirect URI for your application
29 | string sid = redirectURIForSsoWithoutBroker.Host.ToUpper();
30 |
31 | // only used in the .WithBroker scenario.
32 | string redirectUriWithWAM = $"ms-appx-web://microsoft.aad.brokerplugin/{sid}";
33 |
34 | // Then use the following:
35 | LoadApplication(new UserDetailsClient.App(redirectURIForSsoWithoutBroker.AbsoluteUri));
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 |
2 | using Foundation;
3 | using Microsoft.Identity.Client;
4 | using UIKit;
5 |
6 | namespace UserDetailsClient.iOS
7 | {
8 | // The UIApplicationDelegate for the application. This class is responsible for launching the
9 | // User Interface of the application, as well as listening (and optionally responding) to
10 | // application events from iOS.
11 | [Register("AppDelegate")]
12 | public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
13 | {
14 | //
15 | // This method is invoked when the application has loaded and is ready to run. In this
16 | // method you should instantiate the window, load the UI into it and then make the window
17 | // visible.
18 | //
19 | // You have 17 seconds to return from this method, or iOS will terminate your application.
20 | //
21 | public override bool FinishedLaunching(UIApplication app, NSDictionary options)
22 | {
23 | global::Xamarin.Forms.Forms.Init();
24 | LoadApplication(new App());
25 | App.ParentWindow = null; // no UI parent on iOS
26 | return base.FinishedLaunching(app, options);
27 | }
28 |
29 | public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
30 | {
31 | AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url);
32 | return true;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("UserDetailsClient.iOS")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("UserDetailsClient.iOS")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("UserDetailsClient.iOS")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("UserDetailsClient.iOS")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/Properties/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
9 |
10 |
11 |
12 |
13 |
14 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("active_directory_xamarin_intune.iOS")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("active_directory_xamarin_intune.iOS")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("72bdc44f-c588-44f3-b6df-9aace7daafdd")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | FPCL.WIndows
7 | joaqu
8 | Assets\StoreLogo.png
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
8 |
9 |
28 |
29 |
32 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient/App.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Identity.Client;
2 | using System;
3 | using Xamarin.Forms;
4 |
5 | namespace UserDetailsClient
6 | {
7 | public class App : Application
8 | {
9 | public static IPublicClientApplication PCA = null;
10 |
11 | ///
12 | /// The ClientID is the Application ID found in the portal (https://go.microsoft.com/fwlink/?linkid=2083908).
13 | /// You can use the below id however if you create an app of your own you should replace the value here.
14 | ///
15 | public static string ClientID = "4a1aa1d5-c567-49d0-ad0b-cd957a47f842"; //msidentity-samples-testing tenant
16 |
17 | public static string[] Scopes = { "User.Read" };
18 | public static string Username = string.Empty;
19 |
20 | public static object ParentWindow { get; set; }
21 |
22 | public App(string specialRedirectUri = null)
23 | {
24 | PCA = PublicClientApplicationBuilder.Create(ClientID)
25 | .WithRedirectUri(specialRedirectUri?? $"msal{ClientID}://auth")
26 | .WithIosKeychainSecurityGroup("com.microsoft.adalcache")
27 | .Build();
28 |
29 | MainPage = new NavigationPage(new UserDetailsClient.MainPage());
30 | }
31 |
32 | protected override void OnStart()
33 | {
34 | // Handle when your app starts
35 | }
36 |
37 | protected override void OnSleep()
38 | {
39 | // Handle when your app sleeps
40 | }
41 |
42 | protected override void OnResume()
43 | {
44 | // Handle when your app resumes
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | FPCL.WIndows
7 | joaqu
8 | Assets\StoreLogo.png
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.Droid/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.xml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable-hdpi/
12 | icon.png
13 |
14 | drawable-ldpi/
15 | icon.png
16 |
17 | drawable-mdpi/
18 | icon.png
19 |
20 | layout/
21 | main.xml
22 |
23 | values/
24 | strings.xml
25 |
26 | In order to get the build system to recognize Android resources, set the build action to
27 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
28 | instead operate on resource IDs. When you compile an Android application that uses resources,
29 | the build system will package the resources for distribution and generate a class called
30 | "Resource" that contains the tokens for each one of the resources included. For example,
31 | for the above Resources layout, this is what the Resource class would expose:
32 |
33 | public class Resource {
34 | public class drawable {
35 | public const int icon = 0x123;
36 | }
37 |
38 | public class layout {
39 | public const int main = 0x456;
40 | }
41 |
42 | public class strings {
43 | public const int first_string = 0xabc;
44 | public const int second_string = 0xbcd;
45 | }
46 | }
47 |
48 | You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main
49 | to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
50 | string in the dictionary file values/strings.xml.
51 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.Droid/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.xml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable-hdpi/
12 | icon.png
13 |
14 | drawable-ldpi/
15 | icon.png
16 |
17 | drawable-mdpi/
18 | icon.png
19 |
20 | layout/
21 | main.xml
22 |
23 | values/
24 | strings.xml
25 |
26 | In order to get the build system to recognize Android resources, set the build action to
27 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
28 | instead operate on resource IDs. When you compile an Android application that uses resources,
29 | the build system will package the resources for distribution and generate a class called
30 | "Resource" that contains the tokens for each one of the resources included. For example,
31 | for the above Resources layout, this is what the Resource class would expose:
32 |
33 | public class Resource {
34 | public class drawable {
35 | public const int icon = 0x123;
36 | }
37 |
38 | public class layout {
39 | public const int main = 0x456;
40 | }
41 |
42 | public class strings {
43 | public const int first_string = 0xabc;
44 | public const int second_string = 0xbcd;
45 | }
46 | }
47 |
48 | You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main
49 | to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
50 | string in the dictionary file values/strings.xml.
51 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/Resources/AboutResources.txt:
--------------------------------------------------------------------------------
1 | Images, layout descriptions, binary blobs and string dictionaries can be included
2 | in your application as resource files. Various Android APIs are designed to
3 | operate on the resource IDs instead of dealing with images, strings or binary blobs
4 | directly.
5 |
6 | For example, a sample Android app that contains a user interface layout (main.xml),
7 | an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
8 | would keep its resources in the "Resources" directory of the application:
9 |
10 | Resources/
11 | drawable-hdpi/
12 | icon.png
13 |
14 | drawable-ldpi/
15 | icon.png
16 |
17 | drawable-mdpi/
18 | icon.png
19 |
20 | layout/
21 | main.xml
22 |
23 | values/
24 | strings.xml
25 |
26 | In order to get the build system to recognize Android resources, set the build action to
27 | "AndroidResource". The native Android APIs do not operate directly with filenames, but
28 | instead operate on resource IDs. When you compile an Android application that uses resources,
29 | the build system will package the resources for distribution and generate a class called
30 | "Resource" that contains the tokens for each one of the resources included. For example,
31 | for the above Resources layout, this is what the Resource class would expose:
32 |
33 | public class Resource {
34 | public class drawable {
35 | public const int icon = 0x123;
36 | }
37 |
38 | public class layout {
39 | public const int main = 0x456;
40 | }
41 |
42 | public class strings {
43 | public const int first_string = 0xabc;
44 | public const int second_string = 0xbcd;
45 | }
46 | }
47 |
48 | You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main
49 | to reference the layout/main.xml file, or Resource.strings.first_string to reference the first
50 | string in the dictionary file values/strings.xml.
51 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 |
5 | using Foundation;
6 | using UIKit;
7 | using Microsoft.Identity.Client;
8 | using Microsoft.Identity.Client.Platforms.iOS;
9 |
10 | namespace UserDetailsClient.iOS
11 | {
12 | // The UIApplicationDelegate for the application. This class is responsible for launching the
13 | // User Interface of the application, as well as listening (and optionally responding) to
14 | // application events from iOS.
15 | [Register("AppDelegate")]
16 | public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
17 | {
18 | //
19 | // This method is invoked when the application has loaded and is ready to run. In this
20 | // method you should instantiate the window, load the UI into it and then make the window
21 | // visible.
22 | //
23 | // You have 17 seconds to return from this method, or iOS will terminate your application.
24 | //
25 | public override bool FinishedLaunching(UIApplication app, NSDictionary options)
26 | {
27 | global::Xamarin.Forms.Forms.Init();
28 | LoadApplication(new App());
29 | App.ParentWindow = new UIViewController(); // iOS broker requires a view controller
30 | return base.FinishedLaunching(app, options);
31 | }
32 |
33 | public override bool OpenUrl(UIApplication app, NSUrl url, string sourceApplication, NSObject annotation)
34 | {
35 | if (AuthenticationContinuationHelper.IsBrokerResponse(sourceApplication))
36 | {
37 | AuthenticationContinuationHelper.SetBrokerContinuationEventArgs(url);
38 | return true;
39 | }
40 |
41 | else if (!AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url))
42 | {
43 | return false;
44 | }
45 |
46 | return true;
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.Droid/Properties/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
18 |
19 |
20 |
21 |
22 |
23 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/MAMWEAuthCallback.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using activedirectoryxamarinintune;
6 | using Microsoft.Intune.Mam.Policy;
7 |
8 | namespace active_directory_xamarin_intune.Droid
9 | {
10 | ///
11 | /// Required by the MAM SDK. A token may be needed very early in the app lifecycle so the ideal
12 | /// place to register the callback is in the OnMAMCreate() method of the app's implementation
13 | /// of IMAMApplication.
14 | /// See https://docs.microsoft.com/en-us/intune/app-sdk-android#account-authentication
15 | ///
16 | class MAMWEAuthCallback : Java.Lang.Object, IMAMServiceAuthenticationCallback
17 | {
18 | ///
19 | /// MAM expects that this method performs silent authentication for the given resourceID
20 | /// Note. This resource is not the same one from the App. The resource is api for MAM service.
21 | ///
22 | /// UPN of the user
23 | /// Active directory ID
24 | /// ID of the resource.
25 | /// Access token
26 | public string AcquireToken(string upn, string aadId, string resourceId)
27 | {
28 | string ret = null;
29 | try
30 | {
31 | // append with /.default
32 | string[] scopes = new string[] { resourceId + "/.default" };
33 |
34 | // do the silent authentication for the resource
35 | var authresult = PCAWrapper.Instance.AcquireTokenSilentAsync(scopes).GetAwaiter().GetResult();
36 | ret = authresult?.AccessToken;
37 | }
38 | catch (Exception ex)
39 | {
40 | // write the exception and return null
41 | System.Diagnostics.Debug.WriteLine(ex.Message);
42 | }
43 |
44 | return ret;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/IntuneSampleApp.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using Android.App;
6 | using Microsoft.Intune.Mam.Client.App;
7 | using Microsoft.Intune.Mam.Client.Notification;
8 | using Microsoft.Intune.Mam.Policy;
9 | using Microsoft.Intune.Mam.Policy.Notification;
10 |
11 | namespace active_directory_xamarin_intune.Droid
12 | {
13 | #if DEBUG
14 | ///
15 | /// Due to an issue with debugging the Xamarin bound MAM SDK the Debuggable = false attribute must be added to the Application in order to enable debugging.
16 | /// Without this attribute the application will crash when launched in Debug mode. Additional investigation is being performed to identify the root cause.
17 | ///
18 | // [Application(Debuggable = false)]
19 | #else
20 | [Application]
21 | #endif
22 | class IntuneSampleApp : MAMApplication
23 | {
24 | public IntuneSampleApp(IntPtr handle, Android.Runtime.JniHandleOwnership transfer)
25 | : base(handle, transfer) { }
26 |
27 | public override void OnMAMCreate()
28 | {
29 | // as per Intune SDK doc, callback registration must be done here.
30 | // https://docs.microsoft.com/en-us/mem/intune/developer/app-sdk-android
31 | IMAMEnrollmentManager mgr = MAMComponents.Get();
32 | mgr.RegisterAuthenticationCallback(new MAMWEAuthCallback());
33 |
34 | // Register the notification receivers to receive MAM notifications.
35 | // Along with other, this will receive notification that the device has been enrolled.
36 | var notificationRcvr = new EnrollmentNotificationReceiver();
37 | IMAMNotificationReceiverRegistry registry = MAMComponents.Get();
38 | registry.RegisterReceiver(notificationRcvr, MAMNotificationType.MamEnrollmentResult);
39 | registry.RegisterReceiver(notificationRcvr, MAMNotificationType.ComplianceStatus);
40 |
41 | base.OnMAMCreate();
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/1-Basic/AppCreationScripts/Cleanup.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding()]
2 | param(
3 | [PSCredential] $Credential,
4 | [Parameter(Mandatory=$False, HelpMessage='Tenant ID (This is a GUID which represents the "Directory ID" of the AzureAD tenant into which you want to create the apps')]
5 | [string] $tenantId
6 | )
7 |
8 | if ((Get-Module -ListAvailable -Name "AzureAD") -eq $null) {
9 | Install-Module "AzureAD" -Scope CurrentUser
10 | }
11 | Import-Module AzureAD
12 | $ErrorActionPreference = 'Stop'
13 |
14 | Function Cleanup
15 | {
16 | <#
17 | .Description
18 | This function removes the Azure AD applications for the sample. These applications were created by the Configure.ps1 script
19 | #>
20 |
21 | # $tenantId is the Active Directory Tenant. This is a GUID which represents the "Directory ID" of the AzureAD tenant
22 | # into which you want to create the apps. Look it up in the Azure portal in the "Properties" of the Azure AD.
23 |
24 | # Login to Azure PowerShell (interactive if credentials are not already provided:
25 | # you'll need to sign-in with creds enabling your to create apps in the tenant)
26 | if (!$Credential -and $TenantId)
27 | {
28 | $creds = Connect-AzureAD -TenantId $tenantId
29 | }
30 | else
31 | {
32 | if (!$TenantId)
33 | {
34 | $creds = Connect-AzureAD -Credential $Credential
35 | }
36 | else
37 | {
38 | $creds = Connect-AzureAD -TenantId $tenantId -Credential $Credential
39 | }
40 | }
41 |
42 | if (!$tenantId)
43 | {
44 | $tenantId = $creds.Tenant.Id
45 | }
46 | $tenant = Get-AzureADTenantDetail
47 | $tenantName = ($tenant.VerifiedDomains | Where { $_._Default -eq $True }).Name
48 |
49 | # Removes the applications
50 | Write-Host "Cleaning-up applications from tenant '$tenantName'"
51 |
52 | Write-Host "Removing 'client' (active-directory-xamarin-native-v2) if needed"
53 | $app=Get-AzureADApplication -Filter "DisplayName eq 'active-directory-xamarin-native-v2'"
54 |
55 | if ($app)
56 | {
57 | Remove-AzureADApplication -ObjectId $app.ObjectId
58 | Write-Host "Removed."
59 | }
60 |
61 | }
62 |
63 | Cleanup -Credential $Credential -tenantId $TenantId
64 |
--------------------------------------------------------------------------------
/2-With-broker/AppCreationScripts/Cleanup.ps1:
--------------------------------------------------------------------------------
1 | [CmdletBinding()]
2 | param(
3 | [PSCredential] $Credential,
4 | [Parameter(Mandatory=$False, HelpMessage='Tenant ID (This is a GUID which represents the "Directory ID" of the AzureAD tenant into which you want to create the apps')]
5 | [string] $tenantId
6 | )
7 |
8 | if ((Get-Module -ListAvailable -Name "AzureAD") -eq $null) {
9 | Install-Module "AzureAD" -Scope CurrentUser
10 | }
11 | Import-Module AzureAD
12 | $ErrorActionPreference = 'Stop'
13 |
14 | Function Cleanup
15 | {
16 | <#
17 | .Description
18 | This function removes the Azure AD applications for the sample. These applications were created by the Configure.ps1 script
19 | #>
20 |
21 | # $tenantId is the Active Directory Tenant. This is a GUID which represents the "Directory ID" of the AzureAD tenant
22 | # into which you want to create the apps. Look it up in the Azure portal in the "Properties" of the Azure AD.
23 |
24 | # Login to Azure PowerShell (interactive if credentials are not already provided:
25 | # you'll need to sign-in with creds enabling your to create apps in the tenant)
26 | if (!$Credential -and $TenantId)
27 | {
28 | $creds = Connect-AzureAD -TenantId $tenantId
29 | }
30 | else
31 | {
32 | if (!$TenantId)
33 | {
34 | $creds = Connect-AzureAD -Credential $Credential
35 | }
36 | else
37 | {
38 | $creds = Connect-AzureAD -TenantId $tenantId -Credential $Credential
39 | }
40 | }
41 |
42 | if (!$tenantId)
43 | {
44 | $tenantId = $creds.Tenant.Id
45 | }
46 | $tenant = Get-AzureADTenantDetail
47 | $tenantName = ($tenant.VerifiedDomains | Where { $_._Default -eq $True }).Name
48 |
49 | # Removes the applications
50 | Write-Host "Cleaning-up applications from tenant '$tenantName'"
51 |
52 | Write-Host "Removing 'client' (active-directory-xamarin-native-v2) if needed"
53 | $app=Get-AzureADApplication -Filter "DisplayName eq 'active-directory-xamarin-native-v2'"
54 |
55 | if ($app)
56 | {
57 | Remove-AzureADApplication -ObjectId $app.ObjectId
58 | Write-Host "Removed."
59 | }
60 |
61 | }
62 |
63 | Cleanup -Credential $Credential -tenantId $TenantId
64 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UIDeviceFamily
6 |
7 | 1
8 | 2
9 |
10 | UISupportedInterfaceOrientations
11 |
12 | UIInterfaceOrientationPortrait
13 | UIInterfaceOrientationLandscapeLeft
14 | UIInterfaceOrientationLandscapeRight
15 |
16 | UISupportedInterfaceOrientations~ipad
17 |
18 | UIInterfaceOrientationPortrait
19 | UIInterfaceOrientationPortraitUpsideDown
20 | UIInterfaceOrientationLandscapeLeft
21 | UIInterfaceOrientationLandscapeRight
22 |
23 | CFBundleURLTypes
24 |
25 |
26 | CFBundleTypeRole
27 | Editor
28 | CFBundleURLName
29 | com.yourcompany.UserDetailsClient
30 | CFBundleURLSchemes
31 |
32 | msala7d8cef0-4145-49b2-a91d-95c54051fa3f
33 |
34 |
35 |
36 | MinimumOSVersion
37 | 7.0
38 | CFBundleDisplayName
39 | UserDetailsClient
40 | CFBundleIdentifier
41 | com.yourcompany.UserDetailsClient
42 | CFBundleVersion
43 | 1.0
44 | CFBundleIconFiles
45 |
46 | Icon-60@2x
47 | Icon-60@3x
48 | Icon-76
49 | Icon-76@2x
50 | Default
51 | Default@2x
52 | Default-568h@2x
53 | Default-Portrait
54 | Default-Portrait@2x
55 | Icon-Small-40
56 | Icon-Small-40@2x
57 | Icon-Small-40@3x
58 | Icon-Small
59 | Icon-Small@2x
60 | Icon-Small@3x
61 |
62 | UILaunchStoryboardName
63 | LaunchScreen
64 |
65 |
66 |
--------------------------------------------------------------------------------
/1-Basic/AppCreationScripts/sample.json:
--------------------------------------------------------------------------------
1 | {
2 | "Sample": {
3 | "Title": "Xamarin.Forms application using MSAL.NET to acquire an access token and call Microsoft Graph API",
4 | "Level": 200,
5 | "Client": "Xamarin (iOS, Android, UWP)",
6 | "Service": "Microsoft Graph",
7 | "RepositoryUrl": "active-directory-xamarin-native-v2",
8 | "Endpoint": "AAD v2.0"
9 | },
10 |
11 | /*
12 | This section describes the Azure AD Applications to configure, and their dependencies
13 | */
14 | "AADApps": [
15 | {
16 | "Id": "client",
17 | "Name": "active-directory-xamarin-native-v2",
18 | "Kind": "Mobile",
19 | "ReplyUrls": "urn:ietf:wg:oauth:2.0:oob",
20 | "RequiredResourcesAccess": [
21 | {
22 | "Resource": "Microsoft Graph",
23 | "DelegatedPermissions": [ "User.Read" ]
24 | }
25 | ]
26 | }
27 | ],
28 |
29 | /*
30 | This section describes how to update the code in configuration files from the apps coordinates, once the apps
31 | are created in Azure AD.
32 | Each section describes a configuration file, for one of the apps, it's type (XML, JSon, plain text), its location
33 | with respect to the root of the sample, and the mappping (which string in the config file is mapped to which value
34 | */
35 | "CodeConfiguration": [
36 | {
37 | "App": "client",
38 | "SettingKind": "Replace",
39 | "SettingFile": "\\..\\UserDetailsClient\\UserDetailsClient\\App.cs",
40 | "Mappings": [
41 | {
42 | "key": "7d8cef0-4145-49b2-a91d-95c54051fa3f",
43 | "value": ".AppId"
44 | }
45 | ]
46 | },
47 | {
48 | "App": "client",
49 | "SettingKind": "Replace",
50 | "SettingFile": "\\..\\UserDetailsClient\\UserDetailsClient.iOS\\info.plist",
51 | "Mappings": [
52 | {
53 | "key": "7d8cef0-4145-49b2-a91d-95c54051fa3f",
54 | "value": ".AppId"
55 | }
56 | ]
57 | },
58 | {
59 | "App": "client",
60 | "SettingKind": "Replace",
61 | "SettingFile": "\\..\\UserDetailsClient\\UserDetailsClient.Droid\\Properties\\AndroidManifest.xml",
62 | "Mappings": [
63 | {
64 | "key": "7d8cef0-4145-49b2-a91d-95c54051fa3f",
65 | "value": ".AppId"
66 | }
67 | ]
68 | }
69 | ]
70 | }
71 |
--------------------------------------------------------------------------------
/2-With-broker/AppCreationScripts/sample.json:
--------------------------------------------------------------------------------
1 | {
2 | "Sample": {
3 | "Title": "Xamarin.Forms application using MSAL.NET to acquire an access token and call Microsoft Graph API",
4 | "Level": 200,
5 | "Client": "Xamarin (iOS, Android, UWP)",
6 | "Service": "Microsoft Graph",
7 | "RepositoryUrl": "active-directory-xamarin-native-v2",
8 | "Endpoint": "AAD v2.0"
9 | },
10 |
11 | /*
12 | This section describes the Azure AD Applications to configure, and their dependencies
13 | */
14 | "AADApps": [
15 | {
16 | "Id": "client",
17 | "Name": "active-directory-xamarin-native-v2",
18 | "Kind": "Mobile",
19 | "ReplyUrls": "urn:ietf:wg:oauth:2.0:oob",
20 | "RequiredResourcesAccess": [
21 | {
22 | "Resource": "Microsoft Graph",
23 | "DelegatedPermissions": [ "User.Read" ]
24 | }
25 | ]
26 | }
27 | ],
28 |
29 | /*
30 | This section describes how to update the code in configuration files from the apps coordinates, once the apps
31 | are created in Azure AD.
32 | Each section describes a configuration file, for one of the apps, it's type (XML, JSon, plain text), its location
33 | with respect to the root of the sample, and the mappping (which string in the config file is mapped to which value
34 | */
35 | "CodeConfiguration": [
36 | {
37 | "App": "client",
38 | "SettingKind": "Replace",
39 | "SettingFile": "\\..\\UserDetailsClient\\UserDetailsClient\\App.cs",
40 | "Mappings": [
41 | {
42 | "key": "7d8cef0-4145-49b2-a91d-95c54051fa3f",
43 | "value": ".AppId"
44 | }
45 | ]
46 | },
47 | {
48 | "App": "client",
49 | "SettingKind": "Replace",
50 | "SettingFile": "\\..\\UserDetailsClient\\UserDetailsClient.iOS\\info.plist",
51 | "Mappings": [
52 | {
53 | "key": "7d8cef0-4145-49b2-a91d-95c54051fa3f",
54 | "value": ".AppId"
55 | }
56 | ]
57 | },
58 | {
59 | "App": "client",
60 | "SettingKind": "Replace",
61 | "SettingFile": "\\..\\UserDetailsClient\\UserDetailsClient.Droid\\Properties\\AndroidManifest.xml",
62 | "Mappings": [
63 | {
64 | "key": "7d8cef0-4145-49b2-a91d-95c54051fa3f",
65 | "value": ".AppId"
66 | }
67 | ]
68 | }
69 | ]
70 | }
71 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient/App.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Identity.Client;
2 | using Xamarin.Forms;
3 |
4 | namespace UserDetailsClient
5 | {
6 | public class App : Application
7 | {
8 | public static IPublicClientApplication PCA = null;
9 |
10 | ///
11 | /// The ClientID is the Application ID found in the portal (https://go.microsoft.com/fwlink/?linkid=2083908).
12 | /// You can use the below id however if you create an app of your own you should replace the value here.
13 | ///
14 | public static string ClientID = "4a1aa1d5-c567-49d0-ad0b-cd957a47f842"; // ms-identity-samples-testing
15 | public const string BrokerRedirectUriOnIos = "msauth.com.yourcompany.UserDetailsClient://auth";
16 |
17 | //The redirect uri on Android will need to be created based on the signature of the .APK used to sign it.
18 | //This means that it will be different depending on where this sample is run because Visual Studio creates
19 | //a unique signing key for debugging purposes on every machine. You can figure out what that signature will be by running the following commands
20 | //- For Windows: `keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64`
21 | //- For Mac: `keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64`
22 | //For more details, please visit https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-net-use-brokers-with-xamarin-apps
23 | public const string BrokerRedirectUriOnAndroid = "msauth://UserDetailsClient.Droid/{Your package signature}";
24 |
25 | public static string[] Scopes = { "User.Read" };
26 | public static string Username = string.Empty;
27 |
28 | public static object ParentWindow { get; set; }
29 |
30 | public App()
31 | {
32 | MainPage = new NavigationPage(new UserDetailsClient.MainPage());
33 | }
34 |
35 | protected override void OnStart()
36 | {
37 | // Handle when your app starts
38 | }
39 |
40 | protected override void OnSleep()
41 | {
42 | // Handle when your app sleeps
43 | }
44 |
45 | protected override void OnResume()
46 | {
47 | // Handle when your app resumes
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/IntuneMAMConnector.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Diagnostics;
6 | using System.Threading.Tasks;
7 | using activedirectoryxamarinintune;
8 | using Android.Util;
9 | using Microsoft.Identity.Client;
10 | using Microsoft.Intune.Mam.Client.App;
11 | using Microsoft.Intune.Mam.Policy;
12 |
13 | [assembly: Xamarin.Forms.Dependency(typeof(active_directory_xamarin_intune.Droid.IntuneMAMConnector))]
14 | namespace active_directory_xamarin_intune.Droid
15 | {
16 | public class IntuneMAMConnector : IIntuneMAMConnector
17 | {
18 | ///
19 | /// Perform registration with MAM
20 | ///
21 | ///
22 | ///
23 | public async Task DoMAMRegisterAsync(IntuneAppProtectionPolicyRequiredException exProtection)
24 | {
25 | Log.Info(GetType().Name, "***Begin DoMAMRegisterAsync");
26 | Debug.WriteLine("***Begin DoMAMRegisterAsync");
27 | // reset the registered event
28 | PCAWrapper.MAMRegsiteredEvent.Reset();
29 |
30 | // Invoke compliance API on a different thread
31 | await Task.Run(() =>
32 | {
33 | Log.Info(GetType().Name, "Attempting to remediateCompliance.");
34 | Debug.WriteLine("***DoMAMRegisterAsync->RemediateCompliance");
35 | IMAMComplianceManager mgr = MAMComponents.Get();
36 | mgr.RemediateCompliance(exProtection.Upn, exProtection.AccountUserId, exProtection.TenantId, exProtection.AuthorityUrl, true);
37 | }).ConfigureAwait(false);
38 |
39 |
40 | // wait till the registration completes
41 | // Note: This is a sample app for MSAL.NET. Scenarios such as what if enrollment fails or user chooses not to enroll will be as
42 | // per the business requirements of the app and not considered in the sample app.
43 | Debug.WriteLine("***DoMAMRegisterAsync->Pre-Wait");
44 | Log.Info(GetType().Name, "***DoMAMRegisterAsync->Pre-Wait");
45 | PCAWrapper.MAMRegsiteredEvent.WaitOne();
46 | Debug.WriteLine("***DoMAMRegisterAsync->Post-Wait");
47 | Log.Info(GetType().Name, "***DoMAMRegisterAsync->Post-Wait");
48 | }
49 |
50 | public void Unenroll()
51 | {
52 | // Not implpemented on Android by Broker. Known issue.
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
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 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UIDeviceFamily
6 |
7 | 1
8 | 2
9 |
10 | UISupportedInterfaceOrientations
11 |
12 | UIInterfaceOrientationPortrait
13 | UIInterfaceOrientationLandscapeLeft
14 | UIInterfaceOrientationLandscapeRight
15 |
16 | UISupportedInterfaceOrientations~ipad
17 |
18 | UIInterfaceOrientationPortrait
19 | UIInterfaceOrientationPortraitUpsideDown
20 | UIInterfaceOrientationLandscapeLeft
21 | UIInterfaceOrientationLandscapeRight
22 |
23 | LSApplicationQueriesSchemes
24 |
25 | msauthv2
26 | msauthv3
27 |
28 | CFBundleURLTypes
29 |
30 |
31 | CFBundleTypeRole
32 | Editor
33 | CFBundleURLName
34 | com.yourcompany.UserDetailsClient
35 | CFBundleURLSchemes
36 |
37 | msal4a1aa1d5-c567-49d0-ad0b-cd957a47f842
38 | msauth.com.yourcompany.UserDetailsClient
39 |
40 |
41 |
42 | MinimumOSVersion
43 | 7.0
44 | CFBundleDisplayName
45 | UserDetailsClient
46 | CFBundleIdentifier
47 | com.yourcompany.UserDetailsClient
48 | CFBundleVersion
49 | 1.0
50 | CFBundleIconFiles
51 |
52 | Icon-60@2x
53 | Icon-60@3x
54 | Icon-76
55 | Icon-76@2x
56 | Default
57 | Default@2x
58 | Default-568h@2x
59 | Default-Portrait
60 | Default-Portrait@2x
61 | Icon-Small-40
62 | Icon-Small-40@2x
63 | Icon-Small-40@3x
64 | Icon-Small
65 | Icon-Small@2x
66 | Icon-Small@3x
67 |
68 | UILaunchStoryboardName
69 | LaunchScreen
70 |
71 |
72 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.iOS/Resources/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
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 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.iOS/Resources/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
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 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Resources/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
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 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "scale": "2x",
5 | "size": "20x20",
6 | "idiom": "iphone",
7 | "filename": "Icon40.png"
8 | },
9 | {
10 | "scale": "3x",
11 | "size": "20x20",
12 | "idiom": "iphone",
13 | "filename": "Icon60.png"
14 | },
15 | {
16 | "scale": "2x",
17 | "size": "29x29",
18 | "idiom": "iphone",
19 | "filename": "Icon58.png"
20 | },
21 | {
22 | "scale": "3x",
23 | "size": "29x29",
24 | "idiom": "iphone",
25 | "filename": "Icon87.png"
26 | },
27 | {
28 | "scale": "2x",
29 | "size": "40x40",
30 | "idiom": "iphone",
31 | "filename": "Icon80.png"
32 | },
33 | {
34 | "scale": "3x",
35 | "size": "40x40",
36 | "idiom": "iphone",
37 | "filename": "Icon120.png"
38 | },
39 | {
40 | "scale": "2x",
41 | "size": "60x60",
42 | "idiom": "iphone",
43 | "filename": "Icon120.png"
44 | },
45 | {
46 | "scale": "3x",
47 | "size": "60x60",
48 | "idiom": "iphone",
49 | "filename": "Icon180.png"
50 | },
51 | {
52 | "scale": "1x",
53 | "size": "20x20",
54 | "idiom": "ipad",
55 | "filename": "Icon20.png"
56 | },
57 | {
58 | "scale": "2x",
59 | "size": "20x20",
60 | "idiom": "ipad",
61 | "filename": "Icon40.png"
62 | },
63 | {
64 | "scale": "1x",
65 | "size": "29x29",
66 | "idiom": "ipad",
67 | "filename": "Icon29.png"
68 | },
69 | {
70 | "scale": "2x",
71 | "size": "29x29",
72 | "idiom": "ipad",
73 | "filename": "Icon58.png"
74 | },
75 | {
76 | "scale": "1x",
77 | "size": "40x40",
78 | "idiom": "ipad",
79 | "filename": "Icon40.png"
80 | },
81 | {
82 | "scale": "2x",
83 | "size": "40x40",
84 | "idiom": "ipad",
85 | "filename": "Icon80.png"
86 | },
87 | {
88 | "scale": "1x",
89 | "size": "76x76",
90 | "idiom": "ipad",
91 | "filename": "Icon76.png"
92 | },
93 | {
94 | "scale": "2x",
95 | "size": "76x76",
96 | "idiom": "ipad",
97 | "filename": "Icon152.png"
98 | },
99 | {
100 | "scale": "2x",
101 | "size": "83.5x83.5",
102 | "idiom": "ipad",
103 | "filename": "Icon167.png"
104 | },
105 | {
106 | "scale": "1x",
107 | "size": "1024x1024",
108 | "idiom": "ios-marketing",
109 | "filename": "Icon1024.png"
110 | }
111 | ],
112 | "properties": {},
113 | "info": {
114 | "version": 1,
115 | "author": "xcode"
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
17 |
20 |
23 |
24 |
26 |
27 |
28 |
29 |
31 |
32 |
33 |
34 |
36 |
37 |
38 |
39 |
41 |
42 |
43 |
44 |
46 |
47 |
48 |
49 |
52 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 | using System;
4 | using activedirectoryxamarinintune;
5 | using Foundation;
6 | using UIKit;
7 |
8 | using Microsoft.Identity.Client;
9 | using Microsoft.Intune.MAM;
10 |
11 | namespace active_directory_xamarin_intune.iOS
12 | {
13 | // The UIApplicationDelegate for the application. This class is responsible for launching the
14 | // User Interface of the application, as well as listening (and optionally responding) to
15 | // application events from iOS.
16 | [Register("AppDelegate")]
17 | public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
18 | {
19 | private const string iOSRedirectURI = "msauth.com.yourcompany.XamarinIntuneApp://auth"; // TODO - Replace bundleId with your redirectURI
20 |
21 | MainIntuneMAMComplianceDelegate _mamComplianceDelegate = new MainIntuneMAMComplianceDelegate();
22 | MainIntuneMAMEnrollmentDelegate _mamEnrollmentDelegate = new MainIntuneMAMEnrollmentDelegate();
23 | //
24 | // This method is invoked when the application has loaded and is ready to run. In this
25 | // method you should instantiate the window, load the UI into it and then make the window
26 | // visible.
27 | //
28 | // You have 17 seconds to return from this method, or iOS will terminate your application.
29 | //
30 | public override bool FinishedLaunching(UIApplication app, NSDictionary options)
31 | {
32 | global::Xamarin.Forms.Forms.Init();
33 |
34 | // configure platform specific params
35 | PlatformConfigImpl.Instance.RedirectUri = iOSRedirectURI;
36 | PlatformConfigImpl.Instance.ParentWindow = new UIViewController(); // iOS broker requires a view controller
37 |
38 | // register the connector
39 | Xamarin.Forms.DependencyService.Register();
40 |
41 | // register the delegate for IntuneMAMCompliance manager
42 | IntuneMAMComplianceManager.Instance.Delegate = _mamComplianceDelegate;
43 | IntuneMAMEnrollmentManager.Instance.Delegate = _mamEnrollmentDelegate;
44 |
45 | LoadApplication(new App());
46 |
47 | return base.FinishedLaunching(app, options);
48 | }
49 |
50 | public override bool OpenUrl(UIApplication app, NSUrl url,
51 | string sourceApplication,
52 | NSObject annotation)
53 | {
54 | if (AuthenticationContinuationHelper.IsBrokerResponse(sourceApplication))
55 | {
56 | AuthenticationContinuationHelper.SetBrokerContinuationEventArgs(url);
57 | return true;
58 | }
59 |
60 | else if (!AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(url))
61 | {
62 | return false;
63 | }
64 |
65 | return true;
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/MainActivity.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 | using System;
4 | using Android.App;
5 | using Android.Content;
6 | using Android.Widget;
7 | using Android.OS;
8 | using Android.Runtime;
9 | using Android.Support.V4.Widget;
10 | using Android.Support.Design.Widget;
11 | using Android.Views;
12 |
13 | using Microsoft.Identity.Client;
14 | using Microsoft.Intune.Mam.Client.App;
15 | using Microsoft.Intune.Mam.Client.Support.V7.App;
16 | using Microsoft.Intune.Mam.Policy;
17 | using Android.Support.V4.View;
18 | using activedirectoryxamarinintune;
19 | using Android.Content.PM;
20 |
21 | namespace active_directory_xamarin_intune.Droid
22 | {
23 | [Activity(Label = "Xamarin Intune Sample", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
24 | public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
25 | {
26 | private const string AndroidRedirectURI = "msauth://com.yourcompany.xamarinintuneapp/EHyvOdXj4uLXJXDaOMy5lwANmp0="; // TODO - Replace with your redirectURI
27 |
28 | IIntuneMAMConnector _connector = new IntuneMAMConnector();
29 |
30 | protected override void OnMAMCreate(Bundle savedInstanceState)
31 | {
32 | base.OnMAMCreate(savedInstanceState);
33 |
34 | global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
35 |
36 | // configure platform specific params
37 | PlatformConfigImpl.Instance.RedirectUri = AndroidRedirectURI;
38 | PlatformConfigImpl.Instance.ParentWindow = this;
39 |
40 | // register IntuneMAMConnector
41 | Xamarin.Forms.DependencyService.Register();
42 |
43 | LoadApplication(new App());
44 | }
45 | public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
46 | {
47 | Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
48 |
49 | base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
50 | }
51 |
52 | ///
53 | /// This is a callback to continue with the broker base authentication
54 | /// Info abour redirect URI: https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-client-application-configuration#redirect-uri
55 | ///
56 | /// request code
57 | /// result code
58 | /// intent of the actvity
59 | protected override void OnMAMActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
60 | {
61 | base.OnMAMActivityResult(requestCode, resultCode, data);
62 | AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
63 | }
64 |
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDisplayName
6 | Xamarin Intune Sample
7 | CFBundleIdentifier
8 | com.yourcompany.XamarinIntuneApp
9 | CFBundleName
10 | active_directory_xamarin_intune
11 | CFBundleURLTypes
12 |
13 |
14 | CFBundleURLSchemes
15 |
16 | msauth.com.yourcompany.XamarinIntuneApp
17 | msauth.com.yourcompany.XamarinIntuneApp-intunemam
18 | msauth.com.microsoft.intunemam
19 |
20 |
21 |
22 | CFBundleVersion
23 | 1.0
24 | IntuneMAMSettings
25 |
26 | ADALAuthority
27 | https://login.microsoftonline.com/organizations
28 | ADALClientId
29 | TODO - Your Client Id
30 | ADALRedirectUri
31 | msauth.com.yourcompany.XamarinIntuneApp://auth
32 |
33 | LSApplicationQueriesSchemes
34 |
35 | scmx
36 | smsec
37 | microsoft-edge-http
38 | microsoft-edge-http-intunemam
39 | lookoutwork-ase
40 | mvisionmobile
41 | skycure
42 | companyportal
43 | lacoonsecurity
44 | msauthv2
45 | wandera
46 | betteractiveshield
47 | msauthv3
48 | microsoft-edge-https
49 | microsoft-edge-https-intunemam
50 | zips
51 | ms-outlook
52 | ms-outlook-intunemam
53 | smart-ns
54 | https-intunemam
55 | http-intunemam
56 |
57 | MinimumOSVersion
58 | 12.2
59 | UIDeviceFamily
60 |
61 | 1
62 | 2
63 |
64 | UILaunchStoryboardName
65 | LaunchScreen
66 | UISupportedInterfaceOrientations
67 |
68 | UIInterfaceOrientationPortrait
69 | UIInterfaceOrientationLandscapeLeft
70 | UIInterfaceOrientationLandscapeRight
71 |
72 | UISupportedInterfaceOrientations~ipad
73 |
74 | UIInterfaceOrientationPortrait
75 | UIInterfaceOrientationPortraitUpsideDown
76 | UIInterfaceOrientationLandscapeLeft
77 | UIInterfaceOrientationLandscapeRight
78 |
79 | XSAppIconAssets
80 | Assets.xcassets/AppIcon.appiconset
81 |
82 |
83 |
--------------------------------------------------------------------------------
/MauiApps.md:
--------------------------------------------------------------------------------
1 | # MAUI Sample Apps
2 | This file is readme for MAUI sample apps. **It currently supports only iOS, Android, and Windows platforms.**.
3 | A preview package has been published on NuGet. [Microsoft.Identity.Client 4.47.0]( https://www.nuget.org/packages/Microsoft.Identity.Client/4.47.0)
4 |
5 |
6 | ## Prerequisites
7 | To build and run the branch, it will require:
8 | - Visual Studio 2022 Release 17.3.5
9 | - Mac with **XCode 13.3** to compile iOS Apps. Note: Support for XCode 14.0 for MAUI is in RC.
10 |
11 | # Getting started
12 | - Clone this repository
13 | `git clone https://github.com/Azure-Samples/active-directory-xamarin-native-v2.git`
14 | > Given that the name of the sample is pretty long, and so are the name of the referenced NuGet packages, you might want to clone it in a folder close to the root of your hard drive, to avoid file size limitations on Windows.
15 | - Open Visual Studio 2022
16 | - Open the solution
17 | `/MAUI/MauiApps.sln`
18 | - It contains the following projects:
19 |
20 | - MauiAppBasic
21 | This shows how to perform authentication with no broker. It has the common pattern of Acquire Token Silent (ATS) + Acquire Token Interactive (ATI). Note: Android does not support the embedded browser.
22 | - MauiAppWithBroker
23 | This shows how to perform authentication with broker. It has the common pattern of ATS + ATI.
24 | - MauiAppB2C
25 | This shows how to perform authentication with OAuth providers such as Google, Facebook, Microsoft Personal account. It has the common pattern of ATS + ATI.
26 |
27 | ### MauiAppBasic
28 | This performs basic authentication using ATS + ATI flow. There is no broker involved.
29 | The repro steps are:
30 | 1. ATS + ATI
31 | 2. ATS
32 | 3. Logout followed by ATS + ATI
33 |
34 |
35 | The results are as follows:
36 |
37 |
40 |
41 | | Platform | Status |
42 | | ----------- | ----------- |
43 | | iOS (System) | **Works** |
44 | | iOS (Embedded) | **Works** |
45 | | Android (System) | **Works** |
46 | | Android (Embedded) | **Works** |
47 | | WinUI3 | **Works** |
48 |
49 |
50 | ### MauiAppBroker
51 | This performs basic authentication using ATS + ATI flow using broker.
52 | The repro steps are:
53 | 1. ATS + ATI
54 | 2. ATS
55 | 3. Logout followed by ATS + ATI
56 |
57 |
58 | The results are as follows:
59 |
60 |
63 |
64 | | Platform | Status |
65 | | ----------- | ----------- |
66 | | iOS | **Works** |
67 | | Android | **Works** |
68 | | WinUI3 | **Works** |
69 |
70 |
71 | ### MauiAppB2C
72 | This performs basic authentication using ATS + ATI flow using external identity providers.
73 | The repro steps are:
74 | 1. ATS + ATI
75 | 2. ATS
76 | 3. Logout followed by ATS + ATI
77 |
78 |
79 | The results are as follows:
80 |
81 |
84 |
85 | | Platform | Status |
86 | | ----------- | ----------- |
87 | | iOS | **Works** |
88 | | Android | **Works** |
89 | | WinUI3 | **Works** |
90 |
91 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/EnrollmentNotificationReceiver.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Diagnostics;
6 | using activedirectoryxamarinintune;
7 | using Android.Runtime;
8 | using Android.Util;
9 | using Microsoft.Intune.Mam.Client.Notification;
10 | using Microsoft.Intune.Mam.Policy;
11 | using Microsoft.Intune.Mam.Policy.Notification;
12 |
13 | namespace active_directory_xamarin_intune.Droid
14 | {
15 | ///
16 | /// Receives enrollment notifications from the Intune service and performs the corresponding action for the enrollment result.
17 | /// See: https://docs.microsoft.com/en-us/intune/app-sdk-android#mamnotificationreceiver
18 | ///
19 | class EnrollmentNotificationReceiver : Java.Lang.Object, IMAMNotificationReceiver
20 | {
21 | ///
22 | /// When using the MAM-WE APIs found in IMAMEnrollManager, your app wil receive
23 | /// IMAMEnrollmentNotifications back to signal the result of your calls.
24 | /// When enrollment is successful, this will signal that app has been registered and it can proceed ahead.
25 | ///
26 | /// The notification that was received.
27 | ///
28 | /// The receiver should return true if it handled the notification without error(or if it decided to ignore the notification).
29 | /// If the receiver tried to take some action in response to the notification but failed to complete that action it should return false.
30 | ///
31 | public bool OnReceive(IMAMNotification notification)
32 | {
33 | Debug.WriteLine("***Begin EnrollmentNotificationReceiver -> OnReceive");
34 | if (notification.Type == MAMNotificationType.MamEnrollmentResult)
35 | {
36 | Debug.WriteLine("***Begin EnrollmentNotificationReceiver -> OnReceive (notification.Type == MAMNotificationType.MamEnrollmentResult)");
37 | IMAMEnrollmentNotification enrollmentNotification = notification.JavaCast();
38 | MAMEnrollmentManagerResult result = enrollmentNotification.EnrollmentResult;
39 | Debug.WriteLine($"***Begin OnReceive-> Enrollment = {result} Code = {result.Code}");
40 | }
41 | else if (notification.Type == MAMNotificationType.ComplianceStatus)
42 | {
43 | Debug.WriteLine("***Begin EnrollmentNotificationReceiver -> OnReceive (notification.Type == MAMNotificationType.ComplianceStatus)");
44 | IMAMComplianceNotification complianceNotification = notification.JavaCast();
45 | MAMCAComplianceStatus result = complianceNotification.ComplianceStatus;
46 | Debug.WriteLine($"***Begin OnReceive-> Compliance = {result} Code = {result.Code}");
47 | if (result.Equals(MAMCAComplianceStatus.Compliant))
48 | {
49 | Log.Info(GetType().Name, "remediateCompliance succeeded; status = " + result);
50 | Debug.WriteLine("***Begin OnReceive-> Compliant");
51 | // this signals that MAM registration is complete and the app can proceed
52 | PCAWrapper.MAMRegsiteredEvent.Set();
53 | }
54 | else
55 | {
56 | Log.Info(GetType().Name, "remediateCompliance failed; status = " + result);
57 | Log.Info(GetType().Name, complianceNotification.ComplianceErrorTitle);
58 | Log.Info(GetType().Name, complianceNotification.ComplianceErrorMessage);
59 | }
60 | }
61 |
62 | return true;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/2-With-broker/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studo 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | *_i.c
42 | *_p.c
43 | *_i.h
44 | *.ilk
45 | *.meta
46 | *.obj
47 | *.pch
48 | *.pdb
49 | *.pgc
50 | *.pgd
51 | *.rsp
52 | *.sbr
53 | *.tlb
54 | *.tli
55 | *.tlh
56 | *.tmp
57 | *.tmp_proj
58 | *.log
59 | *.vspscc
60 | *.vssscc
61 | .builds
62 | *.pidb
63 | *.svclog
64 | *.scc
65 |
66 | # Chutzpah Test files
67 | _Chutzpah*
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 | *.cachefile
76 |
77 | # Visual Studio profiler
78 | *.psess
79 | *.vsp
80 | *.vspx
81 |
82 | # TFS 2012 Local Workspace
83 | $tf/
84 |
85 | # Guidance Automation Toolkit
86 | *.gpState
87 |
88 | # ReSharper is a .NET coding add-in
89 | _ReSharper*/
90 | *.[Rr]e[Ss]harper
91 | *.DotSettings.user
92 |
93 | # JustCode is a .NET coding addin-in
94 | .JustCode
95 |
96 | # TeamCity is a build add-in
97 | _TeamCity*
98 |
99 | # DotCover is a Code Coverage Tool
100 | *.dotCover
101 |
102 | # NCrunch
103 | _NCrunch_*
104 | .*crunch*.local.xml
105 |
106 | # MightyMoose
107 | *.mm.*
108 | AutoTest.Net/
109 |
110 | # Web workbench (sass)
111 | .sass-cache/
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.[Pp]ublish.xml
131 | *.azurePubxml
132 | # TODO: Comment the next line if you want to checkin your web deploy settings
133 | # but database connection strings (with potential passwords) will be unencrypted
134 | *.pubxml
135 | *.publishproj
136 |
137 | # NuGet Packages
138 | *.nupkg
139 | # The packages folder can be ignored because of Package Restore
140 | **/packages/*
141 | # except build/, which is used as an MSBuild target.
142 | !**/packages/build/
143 | # Uncomment if necessary however generally it will be regenerated when needed
144 | #!**/packages/repositories.config
145 |
146 | # Windows Azure Build Output
147 | csx/
148 | *.build.csdef
149 |
150 | # Windows Store app package directory
151 | AppPackages/
152 |
153 | # Others
154 | *.[Cc]ache
155 | ClientBin/
156 | [Ss]tyle[Cc]op.*
157 | ~$*
158 | *~
159 | *.dbmdl
160 | *.dbproj.schemaview
161 | *.pfx
162 | *.publishsettings
163 | node_modules/
164 | bower_components/
165 |
166 | # RIA/Silverlight projects
167 | Generated_Code/
168 |
169 | # Backup & report files from converting an old project file
170 | # to a newer Visual Studio version. Backup files are not needed,
171 | # because we have git ;-)
172 | _UpgradeReport_Files/
173 | Backup*/
174 | UpgradeLog*.XML
175 | UpgradeLog*.htm
176 |
177 | # SQL Server files
178 | *.mdf
179 | *.ldf
180 |
181 | # Business Intelligence projects
182 | *.rdl.data
183 | *.bim.layout
184 | *.bim_*.settings
185 |
186 | # Microsoft Fakes
187 | FakesAssemblies/
188 |
189 | # Node.js Tools for Visual Studio
190 | .ntvs_analysis.dat
191 |
192 | # Visual Studio 6 build log
193 | *.plg
194 |
195 | # Visual Studio 6 workspace options file
196 | *.opt
197 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studo 2015 cache/options directory
26 | .vs/
27 |
28 | # MSTest test Results
29 | [Tt]est[Rr]esult*/
30 | [Bb]uild[Ll]og.*
31 |
32 | # NUNIT
33 | *.VisualState.xml
34 | TestResult.xml
35 |
36 | # Build Results of an ATL Project
37 | [Dd]ebugPS/
38 | [Rr]eleasePS/
39 | dlldata.c
40 |
41 | *_i.c
42 | *_p.c
43 | *_i.h
44 | *.ilk
45 | *.meta
46 | *.obj
47 | *.pch
48 | *.pdb
49 | *.pgc
50 | *.pgd
51 | *.rsp
52 | *.sbr
53 | *.tlb
54 | *.tli
55 | *.tlh
56 | *.tmp
57 | *.tmp_proj
58 | *.log
59 | *.vspscc
60 | *.vssscc
61 | .builds
62 | *.pidb
63 | *.svclog
64 | *.scc
65 |
66 | # Chutzpah Test files
67 | _Chutzpah*
68 |
69 | # Visual C++ cache files
70 | ipch/
71 | *.aps
72 | *.ncb
73 | *.opensdf
74 | *.sdf
75 | *.cachefile
76 |
77 | # Visual Studio profiler
78 | *.psess
79 | *.vsp
80 | *.vspx
81 |
82 | # TFS 2012 Local Workspace
83 | $tf/
84 |
85 | # Guidance Automation Toolkit
86 | *.gpState
87 |
88 | # ReSharper is a .NET coding add-in
89 | _ReSharper*/
90 | *.[Rr]e[Ss]harper
91 | *.DotSettings.user
92 |
93 | # JustCode is a .NET coding addin-in
94 | .JustCode
95 |
96 | # TeamCity is a build add-in
97 | _TeamCity*
98 |
99 | # DotCover is a Code Coverage Tool
100 | *.dotCover
101 |
102 | # NCrunch
103 | _NCrunch_*
104 | .*crunch*.local.xml
105 |
106 | # MightyMoose
107 | *.mm.*
108 | AutoTest.Net/
109 |
110 | # Web workbench (sass)
111 | .sass-cache/
112 |
113 | # Installshield output folder
114 | [Ee]xpress/
115 |
116 | # DocProject is a documentation generator add-in
117 | DocProject/buildhelp/
118 | DocProject/Help/*.HxT
119 | DocProject/Help/*.HxC
120 | DocProject/Help/*.hhc
121 | DocProject/Help/*.hhk
122 | DocProject/Help/*.hhp
123 | DocProject/Help/Html2
124 | DocProject/Help/html
125 |
126 | # Click-Once directory
127 | publish/
128 |
129 | # Publish Web Output
130 | *.[Pp]ublish.xml
131 | *.azurePubxml
132 | # TODO: Comment the next line if you want to checkin your web deploy settings
133 | # but database connection strings (with potential passwords) will be unencrypted
134 | *.pubxml
135 | *.publishproj
136 |
137 | # NuGet Packages
138 | *.nupkg
139 | # The packages folder can be ignored because of Package Restore
140 | **/packages/*
141 | # except build/, which is used as an MSBuild target.
142 | !**/packages/build/
143 | # Uncomment if necessary however generally it will be regenerated when needed
144 | #!**/packages/repositories.config
145 |
146 | # Windows Azure Build Output
147 | csx/
148 | *.build.csdef
149 |
150 | # Windows Store app package directory
151 | AppPackages/
152 |
153 | # Others
154 | *.[Cc]ache
155 | ClientBin/
156 | [Ss]tyle[Cc]op.*
157 | ~$*
158 | *~
159 | *.dbmdl
160 | *.dbproj.schemaview
161 | *.pfx
162 | *.publishsettings
163 | node_modules/
164 | bower_components/
165 |
166 | # RIA/Silverlight projects
167 | Generated_Code/
168 |
169 | # Backup & report files from converting an old project file
170 | # to a newer Visual Studio version. Backup files are not needed,
171 | # because we have git ;-)
172 | _UpgradeReport_Files/
173 | Backup*/
174 | UpgradeLog*.XML
175 | UpgradeLog*.htm
176 |
177 | # SQL Server files
178 | *.mdf
179 | *.ldf
180 |
181 | # Business Intelligence projects
182 | *.rdl.data
183 | *.bim.layout
184 | *.bim_*.settings
185 |
186 | # Microsoft Fakes
187 | FakesAssemblies/
188 |
189 | # Node.js Tools for Visual Studio
190 | .ntvs_analysis.dat
191 |
192 | # Visual Studio 6 build log
193 | *.plg
194 |
195 | # Visual Studio 6 workspace options file
196 | *.opt
197 | .DS_Store
198 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient.UWP/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.ApplicationModel;
7 | using Windows.ApplicationModel.Activation;
8 | using Windows.Foundation;
9 | using Windows.Foundation.Collections;
10 | using Windows.UI.Xaml;
11 | using Windows.UI.Xaml.Controls;
12 | using Windows.UI.Xaml.Controls.Primitives;
13 | using Windows.UI.Xaml.Data;
14 | using Windows.UI.Xaml.Input;
15 | using Windows.UI.Xaml.Media;
16 | using Windows.UI.Xaml.Navigation;
17 |
18 | namespace UserDetailsClient.UWP
19 | {
20 | ///
21 | /// Provides application-specific behavior to supplement the default Application class.
22 | ///
23 | sealed partial class App : Application
24 | {
25 | ///
26 | /// Initializes the singleton application object. This is the first line of authored code
27 | /// executed, and as such is the logical equivalent of main() or WinMain().
28 | ///
29 | public App()
30 | {
31 | this.InitializeComponent();
32 | this.Suspending += OnSuspending;
33 | }
34 |
35 | ///
36 | /// Invoked when the application is launched normally by the end user. Other entry points
37 | /// will be used such as when the application is launched to open a specific file.
38 | ///
39 | /// Details about the launch request and process.
40 | protected override void OnLaunched(LaunchActivatedEventArgs e)
41 | {
42 |
43 | #if DEBUG
44 | if (System.Diagnostics.Debugger.IsAttached)
45 | {
46 | this.DebugSettings.EnableFrameRateCounter = true;
47 | }
48 | #endif
49 |
50 | Frame rootFrame = Window.Current.Content as Frame;
51 |
52 | // Do not repeat app initialization when the Window already has content,
53 | // just ensure that the window is active
54 | if (rootFrame == null)
55 | {
56 | // Create a Frame to act as the navigation context and navigate to the first page
57 | rootFrame = new Frame();
58 |
59 | rootFrame.NavigationFailed += OnNavigationFailed;
60 |
61 | Xamarin.Forms.Forms.Init(e);
62 |
63 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
64 | {
65 | //TODO: Load state from previously suspended application
66 | }
67 |
68 | // Place the frame in the current Window
69 | Window.Current.Content = rootFrame;
70 | }
71 |
72 | if (rootFrame.Content == null)
73 | {
74 | // When the navigation stack isn't restored navigate to the first page,
75 | // configuring the new page by passing required information as a navigation
76 | // parameter
77 | rootFrame.Navigate(typeof(MainPage), e.Arguments);
78 | }
79 | // Ensure the current window is active
80 | Window.Current.Activate();
81 | }
82 |
83 | ///
84 | /// Invoked when Navigation to a certain page fails
85 | ///
86 | /// The Frame which failed navigation
87 | /// Details about the navigation failure
88 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
89 | {
90 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
91 | }
92 |
93 | ///
94 | /// Invoked when application execution is being suspended. Application state is saved
95 | /// without knowing whether the application will be terminated or resumed with the contents
96 | /// of memory still intact.
97 | ///
98 | /// The source of the suspend request.
99 | /// Details about the suspend request.
100 | private void OnSuspending(object sender, SuspendingEventArgs e)
101 | {
102 | var deferral = e.SuspendingOperation.GetDeferral();
103 | //TODO: Save application state and stop any background activity
104 | deferral.Complete();
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/2-With-broker/UserDetailsClient/UserDetailsClient.UWP/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.ApplicationModel;
7 | using Windows.ApplicationModel.Activation;
8 | using Windows.Foundation;
9 | using Windows.Foundation.Collections;
10 | using Windows.UI.Xaml;
11 | using Windows.UI.Xaml.Controls;
12 | using Windows.UI.Xaml.Controls.Primitives;
13 | using Windows.UI.Xaml.Data;
14 | using Windows.UI.Xaml.Input;
15 | using Windows.UI.Xaml.Media;
16 | using Windows.UI.Xaml.Navigation;
17 |
18 | namespace UserDetailsClient.UWP
19 | {
20 | ///
21 | /// Provides application-specific behavior to supplement the default Application class.
22 | ///
23 | sealed partial class App : Application
24 | {
25 | ///
26 | /// Initializes the singleton application object. This is the first line of authored code
27 | /// executed, and as such is the logical equivalent of main() or WinMain().
28 | ///
29 | public App()
30 | {
31 | this.InitializeComponent();
32 | this.Suspending += OnSuspending;
33 | }
34 |
35 | ///
36 | /// Invoked when the application is launched normally by the end user. Other entry points
37 | /// will be used such as when the application is launched to open a specific file.
38 | ///
39 | /// Details about the launch request and process.
40 | protected override void OnLaunched(LaunchActivatedEventArgs e)
41 | {
42 |
43 | #if DEBUG
44 | if (System.Diagnostics.Debugger.IsAttached)
45 | {
46 | this.DebugSettings.EnableFrameRateCounter = true;
47 | }
48 | #endif
49 |
50 | Frame rootFrame = Window.Current.Content as Frame;
51 |
52 | // Do not repeat app initialization when the Window already has content,
53 | // just ensure that the window is active
54 | if (rootFrame == null)
55 | {
56 | // Create a Frame to act as the navigation context and navigate to the first page
57 | rootFrame = new Frame();
58 |
59 | rootFrame.NavigationFailed += OnNavigationFailed;
60 |
61 | Xamarin.Forms.Forms.Init(e);
62 |
63 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
64 | {
65 | //TODO: Load state from previously suspended application
66 | }
67 |
68 | // Place the frame in the current Window
69 | Window.Current.Content = rootFrame;
70 | }
71 |
72 | if (rootFrame.Content == null)
73 | {
74 | // When the navigation stack isn't restored navigate to the first page,
75 | // configuring the new page by passing required information as a navigation
76 | // parameter
77 | rootFrame.Navigate(typeof(MainPage), e.Arguments);
78 | }
79 | // Ensure the current window is active
80 | Window.Current.Activate();
81 | }
82 |
83 | ///
84 | /// Invoked when Navigation to a certain page fails
85 | ///
86 | /// The Frame which failed navigation
87 | /// Details about the navigation failure
88 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
89 | {
90 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
91 | }
92 |
93 | ///
94 | /// Invoked when application execution is being suspended. Application state is saved
95 | /// without knowing whether the application will be terminated or resumed with the contents
96 | /// of memory still intact.
97 | ///
98 | /// The source of the suspend request.
99 | /// Details about the suspend request.
100 | private void OnSuspending(object sender, SuspendingEventArgs e)
101 | {
102 | var deferral = e.SuspendingOperation.GetDeferral();
103 | //TODO: Save application state and stop any background activity
104 | deferral.Complete();
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/PCAWrapper.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Linq;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 | using Microsoft.Identity.Client;
9 | using Xamarin.Forms;
10 |
11 | namespace activedirectoryxamarinintune
12 | {
13 | ///
14 | /// This is a wrapper for PCA. It is singleton and can be utilized by both application and the MAM callback
15 | ///
16 | public class PCAWrapper
17 | {
18 |
19 | ///
20 | /// This is the singleton used by consumers
21 | ///
22 | static public PCAWrapper Instance { get; } = new PCAWrapper();
23 |
24 | internal IPublicClientApplication PCA { get; }
25 |
26 | // This event coordinates between different callbacks
27 | public static ManualResetEvent MAMRegsiteredEvent { get; } = new ManualResetEvent(false);
28 |
29 | ///
30 | /// The authority for the MSAL PublicClientApplication. Sign in will use this URL.
31 | ///
32 | private const string _authority = "https://login.microsoftonline.com/organizations"; // TODO - For single tenant app replace organizations with your tenant ID or name. Also modify ADALAuthority in info.plist
33 |
34 | // ClientID of the application
35 | private const string ClientId = "TODO "; // TODO - Replace with your client Id. And also replace in the AndroidManifest.xml
36 |
37 | private string[] clientCapabilities = { "ProtApp" }; // It is must to have these capabilities
38 |
39 | // private constructor for singleton
40 | private PCAWrapper()
41 | {
42 | // Create PCA once. Make sure that all the config parameters below are passed
43 | // ClientCapabilities - must have ProtApp
44 | PCA = PublicClientApplicationBuilder
45 | .Create(ClientId)
46 | .WithClientCapabilities(clientCapabilities)
47 | .WithAuthority(_authority)
48 | .WithBroker()
49 | .WithRedirectUri(PlatformConfigImpl.Instance.RedirectUri)
50 | .WithIosKeychainSecurityGroup("com.microsoft.adalcache")
51 | .Build();
52 | }
53 |
54 | ///
55 | /// Perform the intractive acquistion of the token for the given scope
56 | ///
57 | /// desired scopes
58 | /// Parent window
59 | ///
60 | internal async Task AcquireTokenInteractiveAsync(string[] scopes)
61 | {
62 | return await PCA.AcquireTokenInteractive(scopes)
63 | .WithParentActivityOrWindow(PlatformConfigImpl.Instance.ParentWindow)
64 | .WithUseEmbeddedWebView(true)
65 | .ExecuteAsync()
66 | .ConfigureAwait(false);
67 | }
68 |
69 | ///
70 | /// Acquire the token silently
71 | ///
72 | /// desired scopes
73 | /// Authenticaiton result
74 | public async Task AcquireTokenSilentAsync(string[] scopes)
75 | {
76 | var accts = await PCA.GetAccountsAsync().ConfigureAwait(false);
77 | var acct = accts.FirstOrDefault();
78 |
79 | var silentParamBuilder = PCA.AcquireTokenSilent(scopes, acct);
80 | var authResult = await silentParamBuilder
81 | .ExecuteAsync().ConfigureAwait(false);
82 | return authResult;
83 |
84 | }
85 |
86 | ///
87 | /// Signout may not perform the complete signout as company portal may hold
88 | /// the token.
89 | ///
90 | ///
91 | public async Task SignOut()
92 | {
93 | var accounts = await PCA.GetAccountsAsync().ConfigureAwait(false);
94 | foreach (var acct in accounts)
95 | {
96 | await PCA.RemoveAsync(acct).ConfigureAwait(false);
97 | }
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/active-directory-xamarin-intune.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.32802.440
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "active-directory-xamarin-intune", "IntuneClient\active-directory-xamarin-intune\active-directory-xamarin-intune.csproj", "{C44C647D-BC45-4B6B-93C7-3222E3DBD633}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "active-directory-xamarin-intune.Android", "IntuneClient\active-directory-xamarin-intune.Android\active-directory-xamarin-intune.Android.csproj", "{8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "active-directory-xamarin-intune.iOS", "IntuneClient\active-directory-xamarin-intune.iOS\active-directory-xamarin-intune.iOS.csproj", "{EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Debug|iPhone = Debug|iPhone
16 | Debug|iPhoneSimulator = Debug|iPhoneSimulator
17 | Release|Any CPU = Release|Any CPU
18 | Release|iPhone = Release|iPhone
19 | Release|iPhoneSimulator = Release|iPhoneSimulator
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}.Debug|iPhone.ActiveCfg = Debug|Any CPU
25 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}.Debug|iPhone.Build.0 = Debug|Any CPU
26 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
27 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
28 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}.Release|iPhone.ActiveCfg = Release|Any CPU
31 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}.Release|iPhone.Build.0 = Release|Any CPU
32 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
33 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
34 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
37 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Debug|iPhone.ActiveCfg = Debug|Any CPU
38 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Debug|iPhone.Build.0 = Debug|Any CPU
39 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Debug|iPhone.Deploy.0 = Debug|Any CPU
40 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
41 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
42 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
43 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Release|Any CPU.ActiveCfg = Release|Any CPU
44 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Release|Any CPU.Build.0 = Release|Any CPU
45 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Release|Any CPU.Deploy.0 = Release|Any CPU
46 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Release|iPhone.ActiveCfg = Release|Any CPU
47 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Release|iPhone.Build.0 = Release|Any CPU
48 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Release|iPhone.Deploy.0 = Release|Any CPU
49 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
50 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
51 | {8AF40BB2-15C6-4AEA-AEF0-796FCBF8A113}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU
52 | {EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
53 | {EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}.Debug|iPhone.ActiveCfg = Debug|iPhone
54 | {EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}.Debug|iPhone.Build.0 = Debug|iPhone
55 | {EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}.Debug|iPhone.Deploy.0 = Debug|iPhone
56 | {EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
57 | {EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
58 | {EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
59 | {EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}.Release|iPhone.ActiveCfg = Release|iPhone
60 | {EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}.Release|iPhone.Build.0 = Release|iPhone
61 | {EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
62 | {EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
63 | EndGlobalSection
64 | GlobalSection(SolutionProperties) = preSolution
65 | HideSolutionNode = FALSE
66 | EndGlobalSection
67 | GlobalSection(ExtensibilityGlobals) = postSolution
68 | SolutionGuid = {F6AE8938-6C77-4DD0-AF16-F4AF490FC8C7}
69 | EndGlobalSection
70 | EndGlobal
71 |
--------------------------------------------------------------------------------
/.tours/mam-sample-tour.tour:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://aka.ms/codetour-schema",
3 | "title": "MAM Sample tour",
4 | "steps": [
5 | {
6 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/PCAWrapper.cs",
7 | "description": "Wrapper for PCA. This is singleton and wraps the parameters and the desired methods.",
8 | "line": 14
9 | },
10 | {
11 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/PCAWrapper.cs",
12 | "description": "Event is to coordinate between MAM and MSAL",
13 | "line": 27
14 | },
15 | {
16 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/MainPage.xaml.cs",
17 | "description": "Attempt silent login.",
18 | "line": 33
19 | },
20 | {
21 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/MainPage.xaml.cs",
22 | "description": "Attempt AcquireTokenInteractive",
23 | "line": 42
24 | },
25 | {
26 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/MainPage.xaml.cs",
27 | "description": "if the resource requires app protection, this exception is thrown",
28 | "line": 47
29 | },
30 | {
31 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/MainPage.xaml.cs",
32 | "description": "This will perform platform specific registration and wait for it to complete. Do the AcquireTokenSilent after that.\r\nNext will be how it functions on iOS and Android",
33 | "line": 51
34 | },
35 | {
36 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/AppDelegate.cs",
37 | "description": "Platform specific params are registered.",
38 | "line": 35
39 | },
40 | {
41 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/AppDelegate.cs",
42 | "description": "Registers the MAM connector for iOS",
43 | "line": 40
44 | },
45 | {
46 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/AppDelegate.cs",
47 | "description": "Registers callback for the delegate",
48 | "line": 43
49 | },
50 | {
51 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/IntuneMAMConnector.cs",
52 | "description": "Reset the event, call method to make the device compliant and wait for it to finish.",
53 | "line": 14
54 | },
55 | {
56 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/MainIntuneMAMComplianceDelegate.cs",
57 | "description": "In the callback, wait for the device to become compliant and set the event. It will release the event and the app can continue.",
58 | "line": 19
59 | },
60 | {
61 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/IntuneSampleApp.cs",
62 | "description": "Android tour begins here.\r\nAndroid part of MAM requires this special class to perform registration during creation.",
63 | "line": 22
64 | },
65 | {
66 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/IntuneSampleApp.cs",
67 | "description": "Android requires two callbacks. One for enrollment manager and other for receiving MAM notifications.",
68 | "line": 28
69 | },
70 | {
71 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/MainActivity.cs",
72 | "description": "Set platform specific params and register the MAM connectors",
73 | "line": 29
74 | },
75 | {
76 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/IntuneMAMConnector.cs",
77 | "description": "This gets called on Android platform when MSAL throws IntuneAppProtectionPolicyRequiredException",
78 | "line": 20
79 | },
80 | {
81 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/IntuneMAMConnector.cs",
82 | "description": "MAM SDK compliance is called here. It will result in MAMWEAuthCallback.",
83 | "line": 29
84 | },
85 | {
86 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/MAMWEAuthCallback.cs",
87 | "description": "This is called back as part of compliance process. This will ask token for MAM services. Not not the original resource app was seeking. Ensure that the resource has corresct suffix. Acquire the token silenty and return it. This will not throw UIRequired exception as user would have already authenticated for the original resource.\r\nAfter receiving the token, MAM will notify via notificaiton receiver callback.",
88 | "line": 26
89 | },
90 | {
91 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.Android/EnrollmentNotificationReceiver.cs",
92 | "description": "All MAM notifications are received here. If enrollment is successful, release the flag. Then the App will continue.",
93 | "line": 31
94 | },
95 | {
96 | "file": "3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/MainPage.xaml.cs",
97 | "description": "App continues here after the registration with MAM and acquires the desired token.",
98 | "line": 56
99 | }
100 | ],
101 | "ref": "feature/IntuneSample"
102 | }
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation. All rights reserved.
2 | // Licensed under the MIT License.
3 |
4 | using System;
5 | using System.Diagnostics;
6 | using System.Threading.Tasks;
7 | using activedirectoryxamarinintune;
8 | using Microsoft.Identity.Client;
9 | using Xamarin.Forms;
10 |
11 | namespace active_directory_xamarin_intune
12 | {
13 | public partial class MainPage : ContentPage
14 | {
15 | ///
16 | /// The scopes that are protected by conditional access
17 | ///
18 | internal static string[] Scopes = { "https://.sharepoint.com/AllSites.Read" }; // TODO - change scopes per your enterprise app
19 |
20 | public MainPage()
21 | {
22 | InitializeComponent();
23 | }
24 |
25 | async void btnAcquireToken_Clicked(System.Object sender, System.EventArgs e)
26 | {
27 | AuthenticationResult result = null;
28 |
29 | try
30 | {
31 | // attempt silent login.
32 | // If this is very first time and the device is not enrolled, it will throw MsalUiRequiredException
33 | // If the device is enrolled, this will succeed.
34 | result = await PCAWrapper.Instance.AcquireTokenSilentAsync(Scopes).ConfigureAwait(false);
35 |
36 | await ShowMessage("First AcquireTokenTokenSilent call", result.AccessToken).ConfigureAwait(false);
37 | }
38 | catch (MsalUiRequiredException)
39 | {
40 | try
41 | {
42 | // This executes UI interaction ot obtain token
43 | result = await PCAWrapper.Instance.AcquireTokenInteractiveAsync(Scopes).ConfigureAwait(false);
44 |
45 | await ShowMessage("First AcquireTokenInteractive call", result.AccessToken).ConfigureAwait(false);
46 | }
47 | catch (IntuneAppProtectionPolicyRequiredException exProtection)
48 | {
49 | result = await HandleIntuneAppProtectionRequired(result, exProtection).ConfigureAwait(false);
50 | }
51 | catch (Exception ex)
52 | {
53 | await ShowMessage("Exception in AcquireTokenInteractiveAsync", ex.Message).ConfigureAwait(false);
54 | }
55 | }
56 | catch (IntuneAppProtectionPolicyRequiredException exProtection)
57 | {
58 | result = await HandleIntuneAppProtectionRequired(result, exProtection).ConfigureAwait(false);
59 | }
60 | catch (Exception ex)
61 | {
62 | await ShowMessage("Exception in AcquireTokenTokenSilent", ex.Message).ConfigureAwait(false);
63 | }
64 | }
65 |
66 | private async Task HandleIntuneAppProtectionRequired(AuthenticationResult result, IntuneAppProtectionPolicyRequiredException exProtection)
67 | {
68 | // if the scope requires App Protection Policy, IntuneAppProtectionPolicyRequiredException is thrown.
69 | // Perform registration operation here and then does the silent token acquisition
70 | var intuneConnector = DependencyService.Get(DependencyFetchTarget.GlobalInstance);
71 | await intuneConnector.DoMAMRegisterAsync(exProtection).ContinueWith(async (arg) =>
72 | {
73 | Debug.WriteLine("***HandleIntuneAppProtectionRequired Continued");
74 | // Now the device is registered, perform token acquisition
75 | try
76 | {
77 | // if no MFA Policy is present, the silent should work.
78 | result = await PCAWrapper.Instance.AcquireTokenSilentAsync(Scopes).ConfigureAwait(false);
79 |
80 | await ShowMessage("AcquireTokenTokenSilent call after Intune registration.", result.AccessToken).ConfigureAwait(false);
81 | }
82 | catch (MsalUiRequiredException)
83 | {
84 | // if MFA policy is present, one needs to AcquireTokenInteractive API
85 | result = await PCAWrapper.Instance.AcquireTokenInteractiveAsync(Scopes).ConfigureAwait(false);
86 |
87 | await ShowMessage("Second AcquireTokenInteractive call after Intune registration.", result.AccessToken).ConfigureAwait(false);
88 | }
89 | catch (Exception ex)
90 | {
91 | await ShowMessage("Exception in AcquireTokenSilentAsync after registration.", ex.Message).ConfigureAwait(false);
92 | }
93 | }).ConfigureAwait(false);
94 | return result;
95 | }
96 |
97 | // display the message
98 | private Task ShowMessage(string title, string message)
99 | {
100 | Dispatcher.BeginInvokeOnMainThread(async () =>
101 | {
102 | await DisplayAlert(title, message, "OK").ConfigureAwait(false);
103 | });
104 |
105 | return Task.CompletedTask;
106 | }
107 |
108 | // called when signout it pressed
109 | async void btnSignOut_Clicked(System.Object sender, System.EventArgs e)
110 | {
111 | var intuneConnector = DependencyService.Get(DependencyFetchTarget.GlobalInstance);
112 | intuneConnector.Unenroll();
113 |
114 | await PCAWrapper.Instance.SignOut().ConfigureAwait(false);
115 | }
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | page_type: sample
3 | languages:
4 | - csharp
5 | - powershell
6 | products:
7 | - azure-active-directory
8 | description: "You have a Xamarin mobile application and you want it to consume Microsoft Graph or your own Web Api using Microsoft Identity Platform to acquire tokens."
9 | urlFragment: active-directory-xamarin-native-v2
10 | ---
11 |
12 | # A Xamarin mobile application using Microsoft identity platform (formerly Azure AD v2.0)
13 |
14 | [](https://identitydivision.visualstudio.com/IDDP/_build/latest?definitionId=32)
15 |
16 | ## About this sample
17 |
18 | ### Scenario
19 |
20 | You have a mobile application and you want it to consume either Microsoft Graph or your own Web API using the **Microsoft Identity Platform** to acquire tokens.
21 |
22 | ### Structure of the repository
23 |
24 | This repository contains a two-part tutorial - a basic scenario and a more advanced with broker scenario. Choose the one that best suits your scenario, or go through both to understand the differences between the implementations.
25 |
26 | Sub folder | Description
27 | ----------------------------- | -----------
28 | [1-Basic](https://github.com/Azure-Samples/active-directory-xamarin-native-v2/tree/master/1-Basic) | This sample app shows how to use the Microsoft identity platform endpoint to sign-in a user interactively and display their profile

29 | [2-With-broker](https://github.com/Azure-Samples/active-directory-xamarin-native-v2/tree/master/2-With-broker) | This chapter adds additional support for the broker (Microsoft Authenticator), which enables more complex scenarios, like device related conditional access and SSO. 
30 |
31 | ## How to run this sample For Xamarin Forms (not MAUI)
32 |
33 | To run this sample, you'll need:
34 |
35 | - [Visual Studio 2019](https://aka.ms/vsdownload). Install or update Visual Studio with the following workloads:
36 | - Universal Windows Platform Development
37 | - Mobile Development with .Net
38 |
39 | Then from the "Individual Components" tab, make sure these additional items are selected:
40 | - Android SDK setup (API level 27)
41 | - Windows 10 SDK (10.0.17134.0)
42 | - Android SDK level 27 (oreo) and 28 (pie), and Android SDK build tools 27.0.3 are also required. These are not installed through the VS Installer, so instead use the Android SDK Manager (Visual Studio > Tools > Android > Android SDK Manager…)
43 | - An Internet connection
44 | - A Windows, OS X, or Linux machine (necessary if you want to run the app on their respective platforms)
45 | - An Azure Active Directory (Azure AD) tenant. For more information on how to get an Azure AD tenant, see [How to get an Azure AD tenant](https://azure.microsoft.com/en-us/documentation/articles/active-directory-howto-tenant/)
46 | - A user account in your Azure AD tenant. This sample will not work with a Microsoft account (formerly Windows Live account). Therefore, if you signed in to the [Azure portal](https://portal.azure.com) with a Microsoft account and have never created a user account in your directory before, you need to do that now.
47 | - Setup [Xamarin.iOS for Visual Studio](https://docs.microsoft.com/en-us/xamarin/ios/get-started/installation/windows/introduction-to-xamarin-ios-for-visual-studio) (if you want to run the iOS app) - This will require Visual Studio on PC, and on a Mac Machine where XCode 14.0 is installed.
48 |
49 | ### Step 1: Clone or download this repository
50 |
51 | From your shell or command line:
52 |
53 | ```Shell
54 | git clone https://github.com/Azure-Samples/active-directory-xamarin-native-v2.git
55 | ```
56 |
57 | or download and exact the repository .zip file.
58 |
59 | > Given that the name of the sample is pretty long, and so are the name of the referenced NuGet packages, you might want to clone it in a folder close to the root of your hard drive, to avoid file size limitations on Windows.
60 |
61 | Then navigate to the sub-folder of your choice, [1-Basic](./1-Basic) or [2-With-broker](./2-With-broker)
62 |
63 | ## Community Help and Support
64 |
65 | Use [Stack Overflow](http://stackoverflow.com/questions/tagged/msal) to get support from the community.
66 | Ask your questions on Stack Overflow first and browse existing issues to see if someone has asked your question before.
67 | Make sure that your questions or comments are tagged with [`msal` `dotnet`].
68 |
69 | If you find a bug in the sample, please raise the issue on [GitHub Issues](../../issues).
70 |
71 | If you find a bug in msal.Net, please raise the issue on [MSAL.NET GitHub Issues](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues).
72 |
73 | To provide a recommendation, visit the following [User Voice page](https://feedback.azure.com/forums/169401-azure-active-directory).
74 |
75 | ## Contributing
76 |
77 | If you'd like to contribute to this sample, see [CONTRIBUTING.MD](/CONTRIBUTING.md).
78 |
79 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
80 |
81 | ## More information
82 |
83 | For more information, see MSAL.NET's conceptual documentation:
84 |
85 | - [Mobile application scenario landing page](https://docs.microsoft.com/azure/active-directory/develop/scenario-mobile-overview)
86 | - [Quickstart: Register an application with the Microsoft identity platform](https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app)
87 | - [Quickstart: Configure a client application to access web APIs](https://docs.microsoft.com/azure/active-directory/develop/quickstart-configure-app-access-web-apis)
88 | - [Use Microsoft Authenticator or Microsoft Intune Company Portal on Xamarin applications](https://docs.microsoft.com/azure/active-directory/develop/msal-net-use-brokers-with-xamarin-apps)
89 |
--------------------------------------------------------------------------------
/1-Basic/UserDetailsClient/UserDetailsClient/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.Identity.Client;
2 | using Newtonsoft.Json.Linq;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Net.Http;
7 | using System.Threading.Tasks;
8 |
9 | using Xamarin.Forms;
10 |
11 | namespace UserDetailsClient
12 | {
13 | public partial class MainPage : ContentPage
14 | {
15 | public MainPage()
16 | {
17 | InitializeComponent();
18 | }
19 |
20 | async void OnSignInSignOut(object sender, EventArgs e)
21 | {
22 | AuthenticationResult authResult = null;
23 | IEnumerable accounts = await App.PCA.GetAccountsAsync().ConfigureAwait(false);
24 | try
25 | {
26 | if (btnSignInSignOut.Text == "Sign in")
27 | {
28 | try
29 | {
30 | IAccount firstAccount = accounts.FirstOrDefault();
31 | authResult = await App.PCA.AcquireTokenSilent(App.Scopes, firstAccount)
32 | .ExecuteAsync()
33 | .ConfigureAwait(false);
34 | }
35 | catch (MsalUiRequiredException)
36 | {
37 | try
38 | {
39 | var builder = App.PCA.AcquireTokenInteractive(App.Scopes)
40 | .WithParentActivityOrWindow(App.ParentWindow);
41 |
42 | if (Device.RuntimePlatform != "UWP")
43 | {
44 | // on Android and iOS, prefer to use the system browser, which does not exist on UWP
45 | SystemWebViewOptions systemWebViewOptions = new SystemWebViewOptions()
46 | {
47 | iOSHidePrivacyPrompt = true,
48 | };
49 |
50 | builder.WithSystemWebViewOptions(systemWebViewOptions);
51 | builder.WithUseEmbeddedWebView(false);
52 | }
53 |
54 | authResult = await builder.ExecuteAsync().ConfigureAwait(false);
55 | }
56 | catch (Exception ex2)
57 | {
58 | Device.BeginInvokeOnMainThread(async () =>
59 | {
60 | await DisplayAlert("Acquire token interactive failed. See exception message for details: ", ex2.Message, "Dismiss");
61 | });
62 | }
63 | }
64 |
65 | if (authResult != null)
66 | {
67 | var content = await GetHttpContentWithTokenAsync(authResult.AccessToken);
68 | UpdateUserContent(content);
69 | }
70 | }
71 | else
72 | {
73 | while (accounts.Any())
74 | {
75 | await App.PCA.RemoveAsync(accounts.FirstOrDefault()).ConfigureAwait(false);
76 | accounts = await App.PCA.GetAccountsAsync().ConfigureAwait(false);
77 | }
78 |
79 |
80 | Device.BeginInvokeOnMainThread(() =>
81 | {
82 | slUser.IsVisible = false;
83 | btnSignInSignOut.Text = "Sign in";
84 | });
85 | }
86 | }
87 | catch (Exception ex)
88 | {
89 | Device.BeginInvokeOnMainThread(async () =>
90 | {
91 | await DisplayAlert("Authentication failed. See exception message for details: ", ex.Message, "Dismiss");
92 | });
93 | }
94 | }
95 |
96 | private void UpdateUserContent(string content)
97 | {
98 | if(!string.IsNullOrEmpty(content))
99 | {
100 | JObject user = JObject.Parse(content);
101 |
102 | Device.BeginInvokeOnMainThread(() =>
103 | {
104 | slUser.IsVisible = true;
105 |
106 | lblDisplayName.Text = user["displayName"].ToString();
107 | lblGivenName.Text = user["givenName"].ToString();
108 | lblId.Text = user["id"].ToString();
109 | lblSurname.Text = user["surname"].ToString();
110 | lblUserPrincipalName.Text = user["userPrincipalName"].ToString();
111 |
112 | btnSignInSignOut.Text = "Sign out";
113 | });
114 | }
115 | }
116 |
117 | public async Task GetHttpContentWithTokenAsync(string token)
118 | {
119 | try
120 | {
121 | //get data from API
122 | HttpClient client = new HttpClient();
123 | HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Get, "https://graph.microsoft.com/v1.0/me");
124 | message.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
125 | HttpResponseMessage response = await client.SendAsync(message).ConfigureAwait(false);
126 | string responseString = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
127 | return responseString;
128 | }
129 | catch(Exception ex)
130 | {
131 | Device.BeginInvokeOnMainThread(async () =>
132 | {
133 | await DisplayAlert("API call to graph failed: ", ex.Message, "Dismiss").ConfigureAwait(false);
134 | });
135 | return ex.ToString();
136 | }
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/3-With-Intune MAM/IntuneClient/active-directory-xamarin-intune.iOS/active-directory-xamarin-intune.iOS.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | iPhoneSimulator
6 | 8.0.30703
7 | 2.0
8 | {EB20B633-5FEA-4AB6-B07D-3CF7E6AA9CF3}
9 | {FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
10 | {6143fdea-f3c2-4a09-aafa-6e230626515e}
11 | Exe
12 | active_directory_xamarin_intune.iOS
13 | Resources
14 | active_directory_xamarin_intune.iOS
15 | true
16 | NSUrlSessionHandler
17 | automatic
18 |
19 |
20 | true
21 | portable
22 | false
23 | bin\iPhoneSimulator\Debug
24 | DEBUG
25 | prompt
26 | 4
27 | x86_64
28 | None
29 | true
30 |
31 |
32 | none
33 | true
34 | bin\iPhoneSimulator\Release
35 | prompt
36 | 4
37 | None
38 | x86_64
39 |
40 |
41 | true
42 | portable
43 | false
44 | bin\iPhone\Debug
45 | DEBUG
46 | prompt
47 | 4
48 | ARM64
49 | iPhone Developer
50 | true
51 | Entitlements.plist
52 | None
53 | -all
54 | true
55 | true
56 |
57 |
58 | none
59 | true
60 | bin\iPhone\Release
61 | prompt
62 | 4
63 | ARM64
64 | iPhone Developer
65 | Entitlements.plist
66 | SdkOnly
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | false
82 |
83 |
84 | false
85 |
86 |
87 | false
88 |
89 |
90 | false
91 |
92 |
93 | false
94 |
95 |
96 | false
97 |
98 |
99 | false
100 |
101 |
102 | false
103 |
104 |
105 | false
106 |
107 |
108 | false
109 |
110 |
111 | false
112 |
113 |
114 | false
115 |
116 |
117 | false
118 |
119 |
120 | false
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 | 4.47.0
134 |
135 |
136 |
137 |
138 | 16.0.1.2
139 |
140 |
141 |
142 |
143 |
144 | {C44C647D-BC45-4B6B-93C7-3222E3DBD633}
145 | active-directory-xamarin-intune
146 |
147 |
148 |
--------------------------------------------------------------------------------