在目录中找不到标识符 [英] Identifier not found in Directory

查看:92
本文介绍了在目录中找不到标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Azure集成到我的应用程序中.我已经在Active Directory的Azure门户上创建了应用程序,并使用ADAL库进行了集成,但是当我运行该应用程序时会出现Microsoft的登录屏幕,并且登录后出现错误.

我收到此错误

对于创建的登录按钮,然后单击按钮调用

  if(mResult!= null){//登出CookieManager cookieManager = CookieManager.getInstance();cookieManager.removeAllCookie();CookieSyncManager.getInstance().sync();authenticationContext.getCache().removeAll();} 别的 {//登录authenticationContext.acquireToken(LoginActivity.this,Constant.CLIENT_ID,Constant.CLIENT_SECRETE_KEY,Constant.REDIRECT_URL,",PromptBehavior.Auto,",回调);//CLIENT_ID =我在应用程序注册处的appid//CLIENT_SECRETE_KEY = Active Directory中已注册应用程序的秘密密钥//REDIRECT_URL =传递有效网址} 

并在LoginActivity的oncreate()中初始化身份验证上下文

  authenticationContext =新的AuthenticationContext(LoginActivity.this,Constant.AUTHORITY_URL,true);//Authority_URL = https://login.windows.net/mydirectoryname.onmicrosoft.com 

用于回调

  @Overridepublic void onActivityResult(int requestCode,int resultCode,Intent data){super.onActivityResult(requestCode,resultCode,data);authenticationContext.onActivityResult(requestCode,resultCode,data);}私人无效showInfo(String msg){Log.e(",msg);}私有AuthenticationCallback< AuthenticationResult>callback = new AuthenticationCallback< AuthenticationResult>(){@Override公共无效onError(Exception exc){showInfo("getToken错误:" + exc.getMessage());}@Override公共无效onSuccess(AuthenticationResult结果){mResult =结果;startActivity(new Intent(LoginActivity.this,SecondActivity.class));如果(mResult.getUserInfo()!= null){Log.v(",用户信息用户ID:" + result.getUserInfo().getUserId()+"displayableId:" + result.getUserInfo().getDisplayableId());}}}; 

并在应用注册中的Azure Portal中获得KEYVAULT和MicrosoftAzureActiveDirectory的许可(登录并读取用户配置文件许可)我在做什么错了?

解决方案

if(结果!=空值&&!result.getAccessToken().isEmpty()){是错误的,添加令牌空检查或添加getStatus成功检查...

是的,ms special创建了错误的android示例[我认为:)];

最简单的方法是打开在AD下创建的应用,然后打开编辑清单:来自样本:AUTHORITY_URL-是来自应用清单(不是android清单;来自广告注册的Web-api应用的添加清单)中的"identifierUris";CLIENT_ID-是appId;RESOURCE_ID-也来自清单;"requiredResourceAccess":[{"resourceAppId":有时它会出现在auth ex消息中;

,您也应该在AD应用程序中添加相同的答复网址;

如果由于某种原因在身份验证后直接重定向到todoactivity,则会导致状态失败,但是如果打开添加用户,则可以看到登录用户信息并登录成功状态; <​​/p>

因此,在修复了该示例之后,它完全可以正常工作,但这是1-2天的艰苦头脑风暴.期望更多来自ms样本的形式,看起来与每年的质量成正比,并且越来越低;

I am integrating Azure in my app.I have created app at Azure portal in Active directory and for integration using ADAL library but when i am running the app getting login screen of Microsoft and after login getting error this.

i am getting this error

For login created button and onclick on button calling this

if (mResult != null) {
        // logout
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.removeAllCookie();
        CookieSyncManager.getInstance().sync();
        authenticationContext.getCache().removeAll();
    } else {
        // login
       authenticationContext.acquireToken(LoginActivity.this,Constant.CLIENT_ID,
                Constant.CLIENT_SECRETE_KEY, Constant.REDIRECT_URL, "", PromptBehavior.Auto, "",
                callback);//CLIENT_ID=my appid at the of app registration //CLIENT_SECRETE_KEY=secret key of registered app in Active Directory //REDIRECT_URL=passing valid url
    }

and initializing authenticationcontext in oncreate() of LoginActivity

 authenticationContext = new AuthenticationContext(LoginActivity.this,
                Constant.AUTHORITY_URL, true);// Authority_URL=https://login.windows.net/mydirectoryname.onmicrosoft.com

for callback

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    authenticationContext.onActivityResult(requestCode, resultCode, data);
}

private void showInfo(String msg) {
    Log.e("", msg);
}

    private AuthenticationCallback<AuthenticationResult> callback = new AuthenticationCallback<AuthenticationResult>() {


        @Override
        public void onError(Exception exc) {
            showInfo("getToken Error:" + exc.getMessage());
        }

        @Override
        public void onSuccess(AuthenticationResult result) {
            mResult = result;
            startActivity(new Intent(LoginActivity.this, SecondActivity.class));


            if (mResult.getUserInfo() != null) {
                Log.v("", "User info userid:" + result.getUserInfo().getUserId()
                        + " displayableId:" + result.getUserInfo().getDisplayableId());

            }
        }
    };

and in Azure Portal in app registration grand the permission of KEYVAULT and MicrosoftAzureActiveDirectory (sign in and read user profile permission) What i am doing wrong?

解决方案

if (result != null && !result.getAccessToken().isEmpty()) { is wrong, add token null check or add getStatus success check...

yes, ms special create bad android sample [ I think :) ];

simplest way is open your app creted under AD and open edit manifest: from sample: AUTHORITY_URL - is "identifierUris" from app manifest (not android manifest; add-manifest from ad registered web-api app); CLIENT_ID - is appId; RESOURCE_ID - is from manifest too; "requiredResourceAccess": [ { "resourceAppId": some times it comes in auth ex message;

and you should add same reply Url at AD app too;

if redirect after auth directly to todoactivity for some reason result failed status, but if open add user you can see there sign-in user info and sign in success status;

So after fix that sample it works at all, but it was a hard 1-2 days brainstorm; expected more form ms sample, looks like with each year qulity is go momre and more low;

这篇关于在目录中找不到标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆