Skip to content

find nameId of specific user with a given loginid in org #414

Open

Description

@davidkarlsen

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
            }
          }
        }
      }
    }

Activity

  1. elimuhub7407 commented on Oct 17, 2021

    @elimuhub7407
  2. stoe commented on Jul 21, 2023

    @stoe
    Member

    @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
            }
          }
        }
      }
    }
  3. JohnLBevan commented on Nov 16, 2023

    @JohnLBevan

    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: "Simon.Borg@example.com") {
              totalCount
              pageInfo {
                hasNextPage
                endCursor
              }
              edges {
                node {
                  user {
                    login
                  }
                  samlIdentity {
                    nameId
                  }
                }
              }
            }
          }
        }
      }
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions