2017-11-06 29 views
2

azure ad b2cディレクトリのユーザーを照会し、すべてのタイプのユーザーのログインメールをプログラムで抽出します。これは私たちがあることを理解:azureのユーザーを識別する方法b2c

  • 標準ユーザー
  • ゲストユーザー(B2B)
  • ローカルユーザー(メールにサインアップしたB2Cユーザー)
  • 社会ユーザー(社会的にサインアップしたB2Cユーザーアカウント)

紺碧の広告グラフエクスプローラを使用してAPI呼び出しを実行している:

https://graph.windows.net/myorganization/users?api-version=1.6 

これらのすべてのユーザーを見ることができます。 (データビットを消毒されている)

例Standardユーザ

{ 
      "odata.type": "Microsoft.DirectoryServices.User", 
      "objectType": "User", 
      "objectId": "8b7c468b-fec4-4ff2-b448-64f99f3fa9ff", 
      "deletionTimestamp": null, 
      "accountEnabled": true, 
      "assignedLicenses": [], 
      "assignedPlans": [], 
      "city": null, 
      "companyName": null, 
      "country": null, 
      "creationType": null, 
      "department": null, 
      "dirSyncEnabled": null, 
      "displayName": "Global User", 
      "employeeId": null, 
      "facsimileTelephoneNumber": null, 
      "givenName": null, 
      "immutableId": null, 
      "isCompromised": null, 
      "jobTitle": null, 
      "lastDirSyncTime": null, 
      "mail": null, 
      "mailNickname": "global.user", 
      "mobile": null, 
      "onPremisesDistinguishedName": null, 
      "onPremisesSecurityIdentifier": null, 
      "otherMails": [], 
      "passwordPolicies": null, 
      "passwordProfile": null, 
      "physicalDeliveryOfficeName": null, 
      "postalCode": null, 
      "preferredLanguage": null, 
      "provisionedPlans": [], 
      "provisioningErrors": [], 
      "proxyAddresses": [], 
      "refreshTokensValidFromDateTime": "2017-10-31T17:20:29Z", 
      "showInAddressList": null, 
      "signInNames": [], 
      "sipProxyAddress": null, 
      "state": null, 
      "streetAddress": null, 
      "surname": null, 
      "telephoneNumber": null, 
      "usageLocation": null, 
      "userIdentities": [], 
      "userPrincipalName": "[email protected]", 
      "userType": "Member" 
     } 

例ゲストユーザ

{ 
      "odata.type": "Microsoft.DirectoryServices.User", 
      "objectType": "User", 
      "objectId": "6458e1fc-c27b-40cb-b83d-2124f0999130", 
      "deletionTimestamp": null, 
      "accountEnabled": true, 
      "assignedLicenses": [], 
      "assignedPlans": [], 
      "city": null, 
      "companyName": null, 
      "country": null, 
      "creationType": null, 
      "department": null, 
      "dirSyncEnabled": null, 
      "displayName": "displayname", 
      "employeeId": null, 
      "facsimileTelephoneNumber": null, 
      "givenName": "givenname", 
      "immutableId": null, 
      "isCompromised": null, 
      "jobTitle": null, 
      "lastDirSyncTime": null, 
      "mail": null, 
      "mailNickname": "qa_theaccesshub.com#EXT#", 
      "mobile": null, 
      "onPremisesDistinguishedName": null, 
      "onPremisesSecurityIdentifier": null, 
      "otherMails": [ 
       "[email protected]" 
      ], 
      "passwordPolicies": null, 
      "passwordProfile": null, 
      "physicalDeliveryOfficeName": null, 
      "postalCode": null, 
      "preferredLanguage": null, 
      "provisionedPlans": [], 
      "provisioningErrors": [], 
      "proxyAddresses": [], 
      "refreshTokensValidFromDateTime": "2017-10-31T15:36:22Z", 
      "showInAddressList": null, 
      "signInNames": [], 
      "sipProxyAddress": null, 
      "state": null, 
      "streetAddress": null, 
      "surname": "surname", 
      "telephoneNumber": null, 
      "usageLocation": null, 
      "userIdentities": [], 
      "userPrincipalName": "qa_theaccesshub.com#EXT#@qa2clientb2ctheaccesshub.onmicrosoft.com", 
      "userType": "Member" 
     } 

例ローカルユーザ

{ 
      "odata.type": "Microsoft.DirectoryServices.User", 
      "objectType": "User", 
      "objectId": "a941e75d-2c1b-4383-9d6c-783c1d008479", 
      "deletionTimestamp": null, 
      "accountEnabled": true, 
      "assignedLicenses": [], 
      "assignedPlans": [], 
      "city": null, 
      "companyName": null, 
      "country": null, 
      "creationType": "LocalAccount", 
      "department": null, 
      "dirSyncEnabled": null, 
      "displayName": "Display Name", 
      "employeeId": null, 
      "facsimileTelephoneNumber": null, 
      "givenName": "Glen", 
      "immutableId": null, 
      "isCompromised": null, 
      "jobTitle": null, 
      "lastDirSyncTime": null, 
      "mail": null, 
      "mailNickname": "98c4f2cf-a452-46a4-a33f-6fb451bc3f59", 
      "mobile": null, 
      "onPremisesDistinguishedName": null, 
      "onPremisesSecurityIdentifier": null, 
      "otherMails": [], 
      "passwordPolicies": "DisablePasswordExpiration", 
      "passwordProfile": null, 
      "physicalDeliveryOfficeName": null, 
      "postalCode": null, 
      "preferredLanguage": null, 
      "provisionedPlans": [], 
      "provisioningErrors": [], 
      "proxyAddresses": [], 
      "refreshTokensValidFromDateTime": "2017-11-03T18:18:36Z", 
      "showInAddressList": null, 
      "signInNames": [ 
       { 
        "type": "emailAddress", 
        "value": "[email protected]" 
       } 
      ], 
      "sipProxyAddress": null, 
      "state": null, 
      "streetAddress": null, 
      "surname": "Martin", 
      "telephoneNumber": null, 
      "usageLocation": null, 
      "userIdentities": [], 
      "userPrincipalName": "[email protected]microsoft.com", 
      "userType": "Member" 
     } 

例社会ユーザー要するに

{ 
      "odata.type": "Microsoft.DirectoryServices.User", 
      "objectType": "User", 
      "objectId": "917bddd5-40d8-4a25-9a6e-8317a6949b48", 
      "deletionTimestamp": null, 
      "accountEnabled": false, 
      "assignedLicenses": [], 
      "assignedPlans": [], 
      "city": null, 
      "companyName": null, 
      "country": null, 
      "creationType": null, 
      "department": null, 
      "dirSyncEnabled": null, 
      "displayName": "Display Name", 
      "employeeId": null, 
      "facsimileTelephoneNumber": null, 
      "givenName": "GivenName", 
      "immutableId": null, 
      "isCompromised": null, 
      "jobTitle": null, 
      "lastDirSyncTime": null, 
      "mail": null, 
      "mailNickname": "unknown", 
      "mobile": null, 
      "onPremisesDistinguishedName": null, 
      "onPremisesSecurityIdentifier": null, 
      "otherMails": [ 
       "[email protected]" 
      ], 
      "passwordPolicies": null, 
      "passwordProfile": { 
       "password": null, 
       "forceChangePasswordNextLogin": true, 
       "enforceChangePasswordPolicy": false 
      }, 
      "physicalDeliveryOfficeName": null, 
      "postalCode": null, 
      "preferredLanguage": null, 
      "provisionedPlans": [], 
      "provisioningErrors": [], 
      "proxyAddresses": [], 
      "refreshTokensValidFromDateTime": "2017-11-02T13:48:09Z", 
      "showInAddressList": null, 
      "signInNames": [], 
      "sipProxyAddress": null, 
      "state": null, 
      "streetAddress": null, 
      "surname": "Surname", 
      "telephoneNumber": null, 
      "usageLocation": null, 
      "userIdentities": [], 
      "userPrincipalName": "[email protected]ub.onmicrosoft.com", 
      "userType": "Member" 
     } 

たちは気づく:

標準ユーザー

  • userPrincipalNameのは、通常の見える
  • ログイン用メールアドレスを見つけることができ
  • :userPrincipalNameの
  • 作成タイプは:nu LL

ゲストユーザーのuserPrincipalNameは、ログイン用メールアドレスを見つけることができ

  • このプライマリドメインに続いて '#のEXTの#' に続く外部ディレクトリのUPNになりそうだ

    • :otherMails [0]
    • 作成タイプは次のとおりです。

    ローカルヌルユーザー

    • のuserPrincipalNameは、このプライマリドメイン
    • ログイン用メールアドレスに続いて、いくつかのオブジェクトIDになりそうで見つけることができます:signInNames [0]。値
    • 作成タイプは次のとおりです。LocalAccount

    社会ユーザー

    • のuserPrincipalNameは、いくつかのオブジェクトIDに続く「cpim_」は、このプライマリドメイン
    • でログイン用メールアドレスを踏襲することが可能になりますで見つかる:otherMails [0]
    • 作成タイプ:null

    私たちはいくつかの傾向を見ることができますが、推測や悪い仮定をしてはいけません。だから私たちは次の質問を持っています:

    1)私たちが見ている4つのタイプのユーザーを知る最も良い方法は何ですか?

    2)ログインを簡単にする方法はありますか(理想的には1つのフィールドとして、これを簡単なマッピングにすることを試みています)。その他:

    If signInNames[0].value is not null use signInNames[0].value 
    Elseif otherMails[0] is not null use otherMails[0] 
    Else userPrincipalName 
    

    3)他のソーシャルユーザーの行動は異なりますか? (私たちは今までFacebookしか行っていません)

    4)ソーシャルユーザーの場合、どのアイデンティティプロバイダが使用されているかを知る最良の方法は何ですか?

    UPDATE 11/8:

    5)LocalAccountユーザーがotherMail値を得ることはありませんなぜ?

    6)LocalAccount以外のユーザーがサインイン名を取得しないのはなぜですか?私はそれがB2C専用に追加されたと思いますか?

    7)また、エンドユーザーは今日ソーシャルアカウントとローカルアカウントを関連付ける機能を持っていないと思いますか? (グラフを利用するアプリを使用しない限り)。

    UPDATE 11/8#2:

    8)は、私が唯一の次の基準を使用して、ソーシャルアカウントでログインすることができますB2C署名アップ個々の曖昧さをなくすことができることを前提とする)今の(それが安全です:

    • 作成タイプがある:ヌル - 彼らは
    • のuserPrincipalNameは、UUIDが続く「cpim_」が付いているローカルユーザじゃないという意味 - 彼らはおそらく、標準またはゲストユーザーではありません意味

    また、より良い方法がありますか?

  • 答えて

    6

    1)これらは相互に排他的なプロパティではありません。たとえば、ローカルアカウント、ゲストまたはメンバーのユーザーは、複数のソーシャルプロファイルをアカウントにリンクすることもできます。基礎となるデータ(Graph APIを介して利用可能)は、何も仮定していません。

    アカウントがローカルユーザーかどうかを確認する最も信頼できる方法は、creationTypeプロパティを調べることです。また、signInNamesを見ることもできます。それは、ユーザーが今後自分のソーシャルプロファイルをリンクさせないことを意味するわけではありません。この機能はB2C標準ポリシーでは公開されていないということだけです。

    2)signInNamesは、確実にユーザーのサインインに使用されます。ただし、ディレクトリに関する限り、ユーザーは複数のsignInNameを持つこともできます。そのため、signInNamesはコレクションです。したがって、公益企業または銀行は、口座IDと電子メールアドレスの両方をsignInNamesとすることができます。

    otherMailsは、ユーザーにサインインするためのプロパティではありません。だからあなたはそれをスキップしたいかもしれません。ディレクトリで重要な機能に使用されていないメールアドレス(otherMails)と考えてください(ログインやパスワードのリセットなどには使用されません)。

    userPrincipalNameを仕事用アカウントに使用します。

    3)すべてのソーシャルアカウントは外部ユーザーIDとみなされ、同じ方法でマッピングされます。 Graph APIではまだ利用できませんが、そうであればユーザーは複数のソーシャルアカウントにリンクすることができるので、コレクションとしても表示されます。

    4)今日はできませんが、将来は来ます。

    ローカルアカウントのユーザーのためにotherMailsに追加するB2Cの標準的な流れにはメールアドレスが存在しないという理由だけで、追加の質問

    5)を回答するUPDATE 11/8。登録に使用したメールアドレスは既にsignInNamesです。グラフAPIを使用すると、otherMailsを追加できます。トークンが発行されると、ローカルアカウントユーザーの場合でもトークンがemailsに表示されます。

    6)非ローカルアカウントのユーザーは、signInNamesを使用してサインインする必要がないため、signInNameを取得しません。職場のアカウントはuserPrincipalNameを代わりに使用します。これはOffice 365、Exchange、またはオンプレミスADに関連付けられます。ソーシャルIDPには外部IDがあります。したがって、今日少なくとも非ローカルアカウントにsignInNamesを使用する必要があるという既知のシナリオはありません。

    7)はい、現時点では、標準ポリシーでローカルアカウントとソーシャルアカウントをリンクすることはできませんが、カスタムポリシーで実行することはできます。まだ外部APIが公開されていないため、Graph APIを使用することはまだできませんが、APIが公開されているときには今後も可能です。

    更新11/24:

    8)あなたはユーザープリンシパル名を見れば、あなたはそれがランダムでわかります。 cpim_はいつでも削除することができ、契約の一部ではありません。実際、IMHOはすでに削除されているため、アプリはそのアプリケーションに依存しません。

    これを正しく判断するには、ユーザーアカウントに新しい「userIdentities」プロパティをアナウンスして、どのソーシャルIDPがリンクされているユーザーアカウントであるかを判断することができます。それがこれを行う最善の方法でしょう。

    +0

    ありがとうございました!それは、残念ながら、私が期待していた答えでした。要するに、現時点では社会的なアカウントのサインインメールを正しく取得できません。プライマリサインインメールがあるとは思わないでください。 好奇心を抱いた質問: 1)なぜLocalAccountユーザーがotherMail値を取得しないのですか? 2)なぜ非LocalAccountユーザーがサインイン名を取得しないのですか?私はそれがB2C専用に追加されたと思いますか? 3)また、エンドユーザーは今日ソーシャルアカウントとローカルアカウントを関連付ける機能を持っていないと思いますか? (グラフを利用するアプリを使用しない限り)。 ありがとうございました – fei0x

    +1

    私は元の投稿にあなたの追加の質問を追加しています。これにより、将来のユーザーはこれをより簡単に見ることができます。 –

    +0

    もう一度おねがいします。これは非常に役に立ちました。私は私の最終的な問題に対処するために、私は最後の質問を1つ追加しました。ありがとうございました – fei0x

    0

    また、あなたはMSOLを通じてアイデンティティプロバイダに関する情報を要求することができます

    Get-MsolUser -UserPrincipalName "<userPrincipalName>" | ConvertTo-Json 
    

    出力例

    { 
        "AlternateEmailAddresses": [ 
         "[email protected]" 
        ], 
        "AlternateMobilePhones": [], 
        "AlternativeSecurityIds": [ 
         { 
          "ExtensionData": "System.Runtime.Serialization.ExtensionDataObject", 
          "IdentityProvider": "google.com", 
          "Key": "49 48 52 56 48 54 51 54 49 55 51 49 55 55 49 57 57 50 54 55 51", 
          "Type": 6 
         } 
        ], 
        "BlockCredential": true, 
        "City": null, 
        "CloudExchangeRecipientDisplayType": null, 
        "Country": null, 
        "Department": null, 
        "DirSyncProvisioningErrors": [], 
        "DisplayName": "User", 
        "Errors": null, 
        "ExtensionData": {}, 
        "Fax": null, 
        "FirstName": null, 
        "ImmutableId": null, 
        "IndirectLicenseErrors": [], 
        "IsBlackberryUser": false, 
        "IsLicensed": false, 
        "LastDirSyncTime": null, 
        "LastName": null, 
        "LastPasswordChangeTimestamp": "/Date(1511791379000)/", 
        "LicenseReconciliationNeeded": false, 
        "Licenses": [], 
        "LiveId": "10032232271E13BD", 
        "MSExchRecipientTypeDetails": null, 
        "MobilePhone": null, 
        "ObjectId": "6f89d1fb-24be-2231-aaa3-a43d7f75db44", 
        "Office": null, 
        "OverallProvisioningStatus": 0, 
        "PasswordNeverExpires": true, 
        "PasswordResetNotRequiredDuringActivate": null, 
        "PhoneNumber": null, 
        "PortalSettings": null, 
        "PostalCode": null, 
        "PreferredLanguage": null, 
        "ProxyAddresses": [], 
        "ReleaseTrack": null, 
        "ServiceInformation": [], 
        "SignInName": "[email protected]m", 
        "SoftDeletionTimestamp": null, 
        "State": null, 
        "StreetAddress": null, 
        "StrongAuthenticationMethods": [], 
        "StrongAuthenticationPhoneAppDetails": [], 
        "StrongAuthenticationProofupTime": null, 
        "StrongAuthenticationRequirements": [], 
        "StrongAuthenticationUserDetails": null, 
        "StrongPasswordRequired": true, 
        "StsRefreshTokensValidFrom": "/Date(1511791379000)/", 
        "Title": null, 
        "UsageLocation": null, 
        "UserLandingPageIdentifierForO365Shell": null, 
        "UserPrincipalName": "[email protected]m", 
        "UserThemeIdentifierForO365Shell": null, 
        "UserType": 1, 
        "ValidationStatus": 1, 
        "WhenCreated": "/Date(1511791381000)/" 
    } 
    

    残念ながら、グラフAPIは、IDプロバイダーリストでフィールドAlternativeSecurityIdsが含まれていません。

    関連する問題