こんにちは、私は、GRAPH APIを使用してAzureのActive Directoryアプリに新しいユーザーを追加しようとしていますが、クライアントを構築するために必要なURLはわかりませんC#では、私が確信している唯一の文字列はclientSecretです。 誰でも助けることができますか? this blog postでXamarin.Androidアプリ(Azure Active Directory)からユーザーを追加
const string authString = "";
const string clientID = "";
const string clientSecret = "";
const string resAzureGraphAPI = "";
const string serviceRootURL = "";
static Uri serviceRoot = new Uri(serviceRootURL);
ActiveDirectoryClient adClient = new ActiveDirectoryClient(
serviceRoot,
async() => await GetAppTokenAsync());
private void But_Click(object sender, EventArgs e)
{
// Create a new user object.
var newUser = new User()
{
// Required settings
DisplayName = "Jay Hamlin",
UserPrincipalName = "[email protected]",
PasswordProfile = new PasswordProfile()
{
Password = "[email protected]!",
ForceChangePasswordNextLogin = false
},
MailNickname = "JayHamlin",
AccountEnabled = true,
// Some (not all) optional settings
GivenName = "Jay",
Surname = "Hamlin",
JobTitle = "Programmer",
Department = "Development",
City = "Dallas",
State = "TX",
Mobile = "214-123-1234",
};
// Add the user to the directory
adClient.Users.AddUserAsync(newUser).Wait();
}`
private static async Task<string> GetAppTokenAsync()
{
// Instantiate an AuthenticationContext for my directory (see authString above).
AuthenticationContext authenticationContext = new AuthenticationContext(authString, false);
// Create a ClientCredential that will be used for authentication.
// This is where the Client ID and Key/Secret from the Azure Management Portal is used.
ClientCredential clientCred = new ClientCredential(clientID, clientSecret);
// Acquire an access token from Azure AD to access the Azure AD Graph (the resource)
// using the Client ID and Key/Secret as credentials.
AuthenticationResult authenticationResult = await authenticationContext.AcquireTokenAsync(resAzureGraphAPI, clientCred);
// Return the access token.
return authenticationResult.AccessToken;
}`
何が問題ですか?問題の程度を知らなければ、あなたを助けることは困難です。あなたの質問を更新してください。 – Demitrian
const string authString = ""; const string clientID = ""; const string clientSecret = ""; const string resAzureGraphAPI = ""; const string serviceRootURL = ""; 私はこの文字列を埋める方法を知らない –