Independentsoft
Professional software libraries for developers
Home
Purchase
Support
Company
Contact
Graph C++
>
Tutorial
> Create user
The following example shows you how to create an user and set user's password.
C++ example
#include
#include "independentsoft/graph/graph_client.hpp" #include "independentsoft/graph/graph_exception.hpp" #include "independentsoft/graph/users/user.hpp" #include "independentsoft/graph/users/password_profile.hpp" using namespace independentsoft::graph; using namespace independentsoft::graph::users; int main() { try { GraphClient client; client.client_id = "67cb3333-209e-454e-b7bd-55a4d201270f"; client.tenant = "independentsoft.onmicrosoft.com"; client.username = "info@independentsoft.onmicrosoft.com"; client.password = "password"; PasswordProfile passwordProfile; passwordProfile.password = "QWERTY$%^123456"; User user1; user1.account_enabled = true; user1.mail_nickname = "alice"; user1.display_name = "Alice"; user1.principal_name = "alice@independentsoft.onmicrosoft.com"; user1.job_title = "Sales manager"; user1.department = "Sales"; user1.office_location = "LA"; user1.password_profile = passwordProfile; User createdUser = sync_wait(client.create_user(user1)); std::cout << "Id = " << createdUser.id << std::endl; } catch (const GraphException& ex) { std::cout << "Error: " << ex.code << std::endl; std::cout << "Message: " << ex.message << std::endl; } return 0; }
Need help? Ask our developers:
Name*
Email*
Message*