Skip to content

Instantly share code, notes, and snippets.

@chgeuer
Last active January 24, 2024 15:48
Show Gist options
  • Save chgeuer/c9a76dffcc8ff6976385effb651881f7 to your computer and use it in GitHub Desktop.
Save chgeuer/c9a76dffcc8ff6976385effb651881f7 to your computer and use it in GitHub Desktop.

Entra Domain Discovery

Mix.install([
  # {:ex_token_toys, path: "C:\\github\\chgeuer\\ex_token_toys"}
  {:ex_token_toys, github: "chgeuer/ex_token_toys"}, 
  {:kino, "~> 0.12.3"}
])

Trying it out

This is an Elixir version of https://aadinternals.com/osint/

Entra.Discovery.get_tenant_id_for_domain("sap.com")
Entra.Discovery.get_all_domains("sap.com")

Run

domain_input = Kino.Input.text("Please enter the domain, like microsoft.com")
case Kino.Input.read(domain_input) |> String.trim() do
  nil -> "**Please enter a domain**"
  "" -> "**Please enter a domain**"
  domain -> Entra.Kino.render_domain_as_markdown_text(domain)
end
|> Kino.Markdown.new()
@domain = microsoft.onmicrosoft.com
###
POST https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://schemas.microsoft.com/exchange/2010/Autodiscover/Autodiscover/GetFederationInformation"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header xmlns:a="http://www.w3.org/2005/08/addressing">
<a:Action soap:mustUnderstand="1">http://schemas.microsoft.com/exchange/2010/Autodiscover/Autodiscover/GetFederationInformation</a:Action>
<a:To soap:mustUnderstand="1">https://autodiscover-s.outlook.com/autodiscover/autodiscover.svc</a:To>
<a:ReplyTo>
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
</soap:Header>
<soap:Body>
<GetFederationInformationRequestMessage xmlns="http://schemas.microsoft.com/exchange/2010/Autodiscover">
<Request><Domain>{{domain}}</Domain></Request>
</GetFederationInformationRequestMessage>
</soap:Body>
</soap: Envelope>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment