platform-samples icon indicating copy to clipboard operation
platform-samples copied to clipboard

find nameId of specific user with a given loginid in org

Open davidkarlsen opened this issue 4 years ago • 3 comments

The query [1] will list all users with samlIds in the org, but how can I craft the query to search for a user with a specific login?

[1]

query Users($org: String!, $first: Int = 100, $after: String) {
      organization(login: $org) {
        samlIdentityProvider {
          externalIdentities(first: $first, after: $after) {
            edges {
              node {
                guid,
                samlIdentity {
                  nameId
                }
                user {
                  login
                }
              }
            }
            pageInfo {
              hasNextPage
              endCursor
            }
          }
        }
      }
    }

davidkarlsen avatar Sep 07 '21 20:09 davidkarlsen

find wordpress nameId of specific user with a given loginid in org

elimuhub7407 avatar Oct 17 '21 15:10 elimuhub7407

https://github.com/github/platform-samples/issues/414#issue-990346628

akiragg avatar Oct 19 '21 22:10 akiragg

@davidkarlsen, just stumbled upon this, hope that after 2+ years the below is still helpful

query user($org: String!, $login: String = null, $after: String = null) {
  organization(login: $org) {
    samlIdentityProvider {
      externalIdentities(login: $login, first: 100, after: $after) {
        nodes {
          guid
          samlIdentity {
            nameId
          }
          user {
            login
            organizationVerifiedDomainEmails(login: $org)
          }
        }
        pageInfo {
          hasNextPage
          endCursor
        }
      }
    }
  }
}

stoe avatar Jul 21 '23 09:07 stoe

Similarly, if you want to search by IdP username (for us, this is the user's UPN/AAD username/email) replace login: with userName:. We use enterprise instead of organization (more here: https://stackoverflow.com/a/50614349/361842)

{
  enterprise(slug: "my-enterprise-name") {
    ownerInfo {
      samlIdentityProvider {
        externalIdentities(after: null, first: 100, userName: "[email protected]") {
          totalCount
          pageInfo {
            hasNextPage
            endCursor
          }
          edges {
            node {
              user {
                login
              }
              samlIdentity {
                nameId
              }
            }
          }
        }
      }
    }
  }
}

JohnLBevan avatar Nov 16 '23 18:11 JohnLBevan