Skip to content

Commit

Permalink
Add Enrollment Id to ATI (#3399)
Browse files Browse the repository at this point in the history
* Added enrollmentId to ATI + safety chk
  • Loading branch information
SameerK-MSFT authored Jun 17, 2022
1 parent 427a7b1 commit a469e1c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ internal static MsalTokenResponse CreateFromiOSBrokerResponse(Dictionary<string,
AccountUserId = homeAcctId != null ? AccountId.ParseFromString(homeAcctId).ObjectId : null,
TenantId = homeAcctId != null ? AccountId.ParseFromString(homeAcctId).TenantId : null,
Upn = (metadataDictionary?.ContainsKey(TokenResponseClaim.Upn) ?? false) ? metadataDictionary[TokenResponseClaim.Upn] : null,
CorrelationId = responseDictionary.ContainsKey(BrokerResponseConst.CorrelationId) ? responseDictionary[BrokerResponseConst.CorrelationId] : null,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ private Dictionary<string, string> CreateBrokerRequestDictionary(
brokerRequest.Add(BrokerParameter.ClientId, authenticationRequestParameters.AppConfig.ClientId);
brokerRequest.Add(BrokerParameter.CorrelationId, authenticationRequestParameters.RequestContext.CorrelationId.ToString());
brokerRequest.Add(BrokerParameter.ClientVersion, MsalIdHelper.GetMsalVersion());
var realEnrollmentId = IntuneEnrollmentIdHelper.GetRawEnrollmentId();
if (!string.IsNullOrEmpty(realEnrollmentId))
{
brokerRequest.Add(BrokerParameter.IntuneEnrollmentIds, realEnrollmentId);
}

// this needs to be case sensitive because the AppBundle is case sensitive
brokerRequest.Add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ internal class IntuneEnrollmentIdHelper
internal static string GetEnrollmentId(ICoreLogger logger)
{
#if iOS
var keychainData = NSUserDefaults.StandardUserDefaults.StringForKey(EnrollmentIdKey);
var keychainData = GetRawEnrollmentId();
if(!string.IsNullOrEmpty(keychainData))
{
try
{
var enrollmentIDs = JsonConvert.DeserializeObject<EnrollmentIDs>(keychainData);

if (enrollmentIDs.EnrollmentIds.Count > 0)
if ((enrollmentIDs?.EnrollmentIds?.Count ?? 0) > 0)
{
return enrollmentIDs.EnrollmentIds[0].EnrollmentId;
}
Expand All @@ -42,6 +42,16 @@ internal static string GetEnrollmentId(ICoreLogger logger)
return string.Empty;
}

internal static string GetRawEnrollmentId()
{
#if iOS
var keychainData = NSUserDefaults.StandardUserDefaults.StringForKey(EnrollmentIdKey);
return keychainData;
#else
return string.Empty;
#endif
}

/// <summary>
/// This class corresponds to the EnrollmentIDs entry in the Keychain
/// </summary>
Expand Down

0 comments on commit a469e1c

Please sign in to comment.