如何在窗口服务器2008中验证AD用户。 [英] How to authenticate AD user in window server 2008.

查看:134
本文介绍了如何在窗口服务器2008中验证AD用户。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Windows Server 2012中使用Ldap通过IP地址验证用户时。它工作正常,

但是当我在窗口服务器2008中使用相同的代码时,它无法正常工作。

它给出异常服务器不可操作。请告诉一些解决方案。我的代码如下。

When I use Ldap for Authenticate user by IP address in windows server 2012. Its working fine,
but when when i use same code in window server 2008 ,its not working.
It gives Exception "Server is not Operational". please tell some solution . My code as below.

Errmsg = "";
string domainAndUsername = "192.168.0.68"+ @"\" + "amar";
DirectoryEntry entry = new DirectoryEntry("192.168.0.68", domainAndUsername, "ABCD");
try
{
  // Bind to the native AdsObject to force authentication.
 // entry.AuthenticationType = AuthenticationTypes.SecureSocketsLayer;
  Object obj = entry.NativeObject;
  DirectorySearcher search = new DirectorySearcher(entry);
  search.Filter = "(SAMAccountName=" + username + ")";
  search.PropertiesToLoad.Add("cn");
  SearchResult result = search.FindOne();
  if (null == result)
  {
      return false;
  }
  // Update the new path to the user in the directory
  LdapPath = result.Path;
  string _filterAttribute = (String)result.Properties["cn"][0];
}
catch (Exception ex)
{
  Errmsg = ex.Message;
  return false;
  throw new Exception("Error authenticating user." + ex.Message);
}
return true;



需要你的帮助。

任何帮助将不胜感激


need your help.
any help would be appreciated

推荐答案

除了明显的情况,你的2008服务器的LDAP不存在(首先检查它!)它可能是一个缓存问题...

在使用条目之前将entry.RefreshCache()添加到您的代码中...
Except the obvious case that your 2008 server's LDAP not there (go and check it first!) it may be a caching issue...
Add entry.RefreshCache() to your code before using entry...


这篇关于如何在窗口服务器2008中验证AD用户。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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