4D Blog

Home Product Microsoft 365: Get user information from Azure

Microsoft 365: Get user information from Azure

July 18, 2022

Product

Many companies are using Microsoft 365 (former Office 365). Besides providing access to Office applications, Microsoft provides an Azure-based Active Directory, allowing users to log in to access services such as Microsoft Sharepoint or OneDrive using a Web Browser.

All Microsoft services use the same Single Sign-On, based on the email address. From 4D v19 R6, 4D NetKit allows you to join this concept, allowing users to log in to your application using their usual company credentials.

Besides allowing Single Sign-On, it will enable to retrieve information for the authenticated user such as email, department, and phone number. If permitted by the administrator, you can even retrieve such details on colleagues from the same company.

Let’s see how it works.

First, to access a user’s information, you’ll need to get access on their behalf and use the New OAuth2 provider command to create your OAuth2 provider:

$param:=New object()
$param.name:="Microsoft"
$param.permission:="signedIn"
$param.clientId:="XXX"
$param.redirectURI:="http://127.0.0.1:50993/authorize/"
$param.scope:="https://graph.microsoft.com/.default"
// Create new OAuth2 object
$tokenProvider:=New OAuth2 provider($param)

When your OAuth2 provider is ready, use the New Office365 provider command to instantiate an object that will manage the access to your Microsoft 365 account through the Microsoft Graph API:

var $Office365 : cs.NetKit.Office365Provider
$Office365:=New Office365 provider($tokenProvider)

user information

You can get the user information like displayName, givenName, and more.

If you are connected in Sign In mode, you can get the current user information:

$currentUser:=$Office365.user.getCurrent()
//$currentUser=
//{displayName:My Name,givenName:Name,mail:myname@mycompany.com,...}

If you belong to Azure AD “work or school” account, you can access the information of a specific user of your organization:

$user:=$Office365.user.get("myname@mycompany.com")

or access the list of all the users of your organization:

$users:=$Office365.user.list()

Check out the documentation for more details, and don’t hesitate to share with us your experience on the 4D forum.

Discuss

Tags 4D NetKit, Authentication, Microsoft 365, v19 R6, v20

Latest related posts

  • October 23, 2025

    Starting Qodly studio is just two clicks away

  • October 22, 2025

    Localize your Qodly Pages: A Practical Guide

  • October 21, 2025

    New Way to Control Your HTTP Responses

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy