Вот сообщение об ошибке, которое я получаю: мы используем логин и пароль для получения токена аутентификации
просто не уверены, какие разрешения нам нужны.
"Microsoft.InformationProtection .Exceptions.AccessDeniedException: служба не приняла токен аутентификации. Вызов:[''] HttpRequest.Id={E0C61208-D90F-49FF-83E0-2A17F8D3DB9A}, CorrelationId=0a882288-d5e3-4b7a-812b-a5dc5a779271, Corre. идентификатор связи .Description=PolicyProfile
в EmailSDK.Program.c__DisplayClass2_0.d.MoveNext() в C:\Users\DaHacker\source\repos\EmailSDK\Program.cs: строка 56"
вот код, который у меня есть, он из краткого руководства MS
MIP.Initialize(MipComponent.File);
// Create ApplicationInfo, setting the clientID from Microsoft Entra App Registration as the ApplicationId.
ApplicationInfo appInfo = new ApplicationInfo()
{
ApplicationId = clientId,
ApplicationName = appName,
ApplicationVersion = "1.0.0"
};
// Instantiate the AuthDelegateImpl object, passing in AppInfo.
AuthDelegateImplementation authDelegate = new AuthDelegateImplementation(appInfo);
// Create MipConfiguration Object
MipConfiguration mipConfiguration = new MipConfiguration(appInfo, "mip_data", LogLevel.Trace ,false);
// Create MipContext using Configuration
using (MipContext mipContext = MIP.CreateMipContext(mipConfiguration))
{
// Initialize and instantiate the File Profile.
// Create the FileProfileSettings object.
// Initialize file profile settings to create/use local state.
FileProfileSettings profileSettings = new FileProfileSettings(mipContext,CacheStorageType.OnDiskEncrypted,
new ConsentDelegateImplementation());
// Load the Profile async and wait for the result.
IFileProfile fileProfile = Task.Run(async () => await MIP.LoadFileProfileAsync(profileSettings)).Result;
// Create a FileEngineSettings object, then use that to add an engine to the profile.
// This pattern sets the engine ID to user1@tenant.com, then sets the identity used to create the engine.
FileEngineSettings engineSettings = new FileEngineSettings("Dahacker@aol.com", authDelegate, "", "en-US");
engineSettings.Identity = new Identity(Dahacker@aol.comm);
IFileEngine fileEngine = null;
try
{
fileEngine = Task.Run(async () => await fileProfile.AddEngineAsync(engineSettings)).Result;
}
catch (Exception ex)
{
// Application Shutdown
// handler = null; // This will be used in later quick starts.
fileEngine = null;
fileProfile = null;
mipContext.ShutDown();
}
public AuthDelegateImplementation(ApplicationInfo appInfo)
{
_appInfo = appInfo;
}
public string AcquireToken(Identity identity, string authority, string resource, string claims)
{
authority = https://graph.microsoft.com/.default;
var authorityUri = new Uri(authority);
authority = String.Format([https://%7b0%7d/%7b1%7d]https://{0}/{1}, authorityUri.Host, "10462954-a52f-469d-9f83-8ac832d15e78");
_app = PublicClientApplicationBuilder.Create(_appInfo.ApplicationId).WithTenantId("10462954-a52f-469d-9f83-8ac832d15e78").Build();
var accounts = (_app.GetAccountsAsync()).GetAwaiter().GetResult();
string[] scopes = new[] { "User.Read.All" };
// string[] scopes = new[] { "Files.ReadWrite.All" };
var result = _app.AcquireTokenByUsernamePassword(scopes, "UserEmail:Dahacker@aol.com", "Password: LetMeIn")
.ExecuteAsync().ConfigureAwait(false).GetAwaiter().GetResult();
return result.AccessToken;
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... e-didnt-ac
Ошибка входа и MIP при использовании C#.AccessDeniedException: служба не приняла токен аутентификации. Испытание:[''] ⇐ C#
Место общения программистов C#
1721215119
Anonymous
Вот сообщение об ошибке, которое я получаю: мы используем логин и пароль для получения токена аутентификации
просто не уверены, какие разрешения нам нужны.
"Microsoft.InformationProtection .Exceptions.AccessDeniedException: служба не приняла токен аутентификации. Вызов:[''] HttpRequest.Id={E0C61208-D90F-49FF-83E0-2A17F8D3DB9A}, CorrelationId=0a882288-d5e3-4b7a-812b-a5dc5a779271, Corre. идентификатор связи .Description=PolicyProfile
в EmailSDK.Program.c__DisplayClass2_0.d.MoveNext() в C:\Users\DaHacker\source\repos\EmailSDK\Program.cs: строка 56"
вот код, который у меня есть, он из краткого руководства MS
MIP.Initialize(MipComponent.File);
// Create ApplicationInfo, setting the clientID from Microsoft Entra App Registration as the ApplicationId.
ApplicationInfo appInfo = new ApplicationInfo()
{
ApplicationId = clientId,
ApplicationName = appName,
ApplicationVersion = "1.0.0"
};
// Instantiate the AuthDelegateImpl object, passing in AppInfo.
AuthDelegateImplementation authDelegate = new AuthDelegateImplementation(appInfo);
// Create MipConfiguration Object
MipConfiguration mipConfiguration = new MipConfiguration(appInfo, "mip_data", LogLevel.Trace ,false);
// Create MipContext using Configuration
using (MipContext mipContext = MIP.CreateMipContext(mipConfiguration))
{
// Initialize and instantiate the File Profile.
// Create the FileProfileSettings object.
// Initialize file profile settings to create/use local state.
FileProfileSettings profileSettings = new FileProfileSettings(mipContext,CacheStorageType.OnDiskEncrypted,
new ConsentDelegateImplementation());
// Load the Profile async and wait for the result.
IFileProfile fileProfile = Task.Run(async () => await MIP.LoadFileProfileAsync(profileSettings)).Result;
// Create a FileEngineSettings object, then use that to add an engine to the profile.
// This pattern sets the engine ID to user1@tenant.com, then sets the identity used to create the engine.
FileEngineSettings engineSettings = new FileEngineSettings("Dahacker@aol.com", authDelegate, "", "en-US");
engineSettings.Identity = new Identity(Dahacker@aol.comm);
IFileEngine fileEngine = null;
try
{
fileEngine = Task.Run(async () => await fileProfile.AddEngineAsync(engineSettings)).Result;
}
catch (Exception ex)
{
// Application Shutdown
// handler = null; // This will be used in later quick starts.
fileEngine = null;
fileProfile = null;
mipContext.ShutDown();
}
public AuthDelegateImplementation(ApplicationInfo appInfo)
{
_appInfo = appInfo;
}
public string AcquireToken(Identity identity, string authority, string resource, string claims)
{
authority = https://graph.microsoft.com/.default;
var authorityUri = new Uri(authority);
authority = String.Format([https://%7b0%7d/%7b1%7d]https://{0}/{1}, authorityUri.Host, "10462954-a52f-469d-9f83-8ac832d15e78");
_app = PublicClientApplicationBuilder.Create(_appInfo.ApplicationId).WithTenantId("10462954-a52f-469d-9f83-8ac832d15e78").Build();
var accounts = (_app.GetAccountsAsync()).GetAwaiter().GetResult();
string[] scopes = new[] { "User.Read.All" };
// string[] scopes = new[] { "Files.ReadWrite.All" };
var result = _app.AcquireTokenByUsernamePassword(scopes, "UserEmail:Dahacker@aol.com", "Password: LetMeIn")
.ExecuteAsync().ConfigureAwait(false).GetAwaiter().GetResult();
return result.AccessToken;
}
Подробнее здесь: [url]https://stackoverflow.com/questions/78759209/entra-and-mip-errror-using-c-sharp-accessdeniedexception-the-service-didnt-ac[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия