我已经在我的系统上安装了 openLDAP,后端引擎为 LDAP。安装时提供的详细信息是:Port-389,IPaddress-"192.168.....",
password-"secret"
,username-bindDN-"cn=name,cn=users,dc=mydomain,dc=com"
我正在尝试创建从 android 模拟器到安装的 LDAP 服务器的连接。我正在使用unboundIdD LDAP SDK for java。编写的代码如下:
public class MainActivity extends Activity implements OnClickListener {
//String address="ldap://server1.mydomain.com";
String address="192.168.....";
int port=389;
String bindDN="CN=name,CN=users,DC=mydomain,DC=com";
String password="secret";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button bt_login=(Button)findViewById(R.id.bt_login);
bt_login.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
public void onClick(View arg0) {
try {
LDAPConnection c = new LDAPConnection(address,port,bindDN,password);
} catch (LDAPException e) {
e.printStackTrace();
}
}
}
但是在模拟器上运行此代码..按下登录按钮后..我得到一个异常。我的错误日志如下:
12-09 19:57:58.968: W/System.err(392): LDAPException(resultCode=52 (unavailable), errorMessage='Proxy operation retry failed', diagnosticMessage='Proxy operation retry failed')
12-09 19:57:58.972: W/System.err(392): at com.unboundid.ldap.sdk.LDAPConnection.bind(LDAPConnection.java:1837)
12-09 19:57:58.972: W/System.err(392): at com.unboundid.ldap.sdk.LDAPConnection.<init>(LDAPConnection.java:637)
12-09 19:57:58.972: W/System.err(392): at com.unboundid.ldap.sdk.LDAPConnection.<init>(LDAPConnection.java:534)
12-09 19:57:58.972: W/System.err(392): at gemini.ldapdemo2.MainActivity.onClick(MainActivity.java:41)
12-09 19:57:58.972: W/System.err(392): at android.view.View.performClick(View.java:2408)
12-09 19:57:58.972: W/System.err(392): at android.view.View$PerformClick.run(View.java:8816)
12-09 19:57:58.972: W/System.err(392): at android.os.Handler.handleCallback(Handler.java:587)
12-09 19:57:58.972: W/System.err(392): at android.os.Handler.dispatchMessage(Handler.java:92)
12-09 19:57:58.972: W/System.err(392): at android.os.Looper.loop(Looper.java:123)
12-09 19:57:58.972: W/System.err(392): at android.app.ActivityThread.main(ActivityThread.java:4627)
12-09 19:57:58.972: W/System.err(392): at java.lang.reflect.Method.invokeNative(Native Method)
12-09 19:57:58.972: W/System.err(392): at java.lang.reflect.Method.invoke(Method.java:521)
12-09 19:57:58.972: W/System.err(392): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-09 19:57:58.972: W/System.err(392): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-09 19:57:58.972: W/System.err(392): at dalvik.system.NativeStart.main(Native Method)
为什么我得到这个例外。请帮助我。我是一个新人。谢谢