我正在尝试在Xamarin中创建针对LDAP的身份验证。我有Main.xaml,我在其中创建了简单的登录表单(Entry Placeholder="*Password”IsPassword=“True”x:Name=“login_password”)和按钮(Button Clicked =“btnLogin_Clicked”Text=“Sign in”x:Name=“btnLogin”)。cs包含LDAP连接的代码。我在那里检查凭据并尝试绑定。
我收到这个错误:“在类型'Main.xaml'中未找到具有正确签名的EventHandler 'btnLogin_Clicked'”。
我在这上面花了这么多时间,还是想不出我做错了什么。我将不胜感激,如果任何人可以帮助我与此或给予我一些建议,我可以搜索的答案。
我的代码:
public void btnLogin_Clicked(object sender,string login_username, string login_password, System.EventArgs e)
{
string searchBase = "dc = it, dc = local";
string searchFilter = "(amemberOf=ALL)";
string ldapHost = "7777.. ";
int ldapPort = 389;
string loginDN = "dc = it, dc = local";
/*if username or passworwd fields are empty show an error*/
if (login_username is null || login_password is null)
{
DisplayAlert("Alert", "Please, enter your credentials", "OK");
}
else
{
/*creating an LDAP instance*/
using (LdapConnection connection = new LdapConnection())
/*here we create new ldap connection*/
try
{
/*connect function will creat socket connection to the server*/
connection.Connect(ldapHost, ldapPort);
connection.Bind(string.Format("{0}@{1}", loginDN, login_username), login_password);
LdapSearchQueue queue = connection.Search(searchBase,
LdapConnection.SCOPE_ONE, searchFilter, null, false, (LdapSearchQueue)
null, (LdapSearchConstraints)null);
LdapMessage message;
while ((message = queue.getResponse()) != null)
{
if (message is LdapSearchResult)
{
/*display message if connect*/
DisplayAlert("" ," logged in ", "OK ");
}
else
{
/*if the message is not null but the login was failed*/
DisplayAlert("", "Login failed", "OK ");
}...
字符串
1条答案
按热度按时间w1jd8yoj1#
按钮的事件处理程序具有签名
字符串
您不能只向签名添加额外的参数