protected string GetCurrentUsersObjectId() { if (DefaultContext.Subscription == null) { throw new InvalidOperationException(PSKeyVaultProperties.Resources.InvalidSelectedSubscription); } if (DefaultContext.Account == null) { throw new InvalidOperationException(PSKeyVaultProperties.Resources.NoDefaultUserAccount); } string objectId = null; if (DefaultContext.Account.Type == AzureAccount.AccountType.User) { #if NETSTANDARD objectId = ActiveDirectoryClient.GetObjectId(new ADObjectFilterOptions { UPN = DefaultContext.Account.Id }).ToString(); #else var userFetcher = ActiveDirectoryClient.Me.ToUser(); var user = userFetcher.ExecuteAsync().Result; objectId = user.ObjectId; #endif } return(objectId); }
protected string GetCurrentUsersObjectId() { if (DefaultContext.Subscription == null) { throw new InvalidOperationException(PSKeyVaultProperties.Resources.InvalidSelectedSubscription); } if (DefaultContext.Account == null) { throw new InvalidOperationException(PSKeyVaultProperties.Resources.NoDefaultUserAccount); } string objectId = null; if (DefaultContext.Account.Type == AzureAccount.AccountType.User) { objectId = ActiveDirectoryClient.GetObjectId(new ADObjectFilterOptions()).ToString(); } return(objectId); }