相关疑难解决方法(0)

如何通过LDAP + SSL验证Active Directory信誉?

我正在尝试使用.NET 3.5 System.DirectoryServices.AccountManagement命名空间通过SSL加密的LDAP连接验证针对我们的Active Directory LDAP服务器的用户凭据.这是示例代码:

using (var pc = new PrincipalContext(ContextType.Domain, "sd.example.com:389", "DC=sd,DC=example,DC=com", ContextOptions.Negotiate))
{
    return pc.ValidateCredentials(_username, _password);
}
Run Code Online (Sandbox Code Playgroud)

此代码在不安全的LDAP(端口389)上工作正常,但我宁愿不以明文形式传输用户/传递组合.但是,当我更改为LDAP + SSL(端口636)时,我得到以下异常:

System.DirectoryServices.Protocols.DirectoryOperationException: The server cannot handle directory requests.
  at System.DirectoryServices.Protocols.ErrorChecking.CheckAndSetLdapError(Int32 error)
  at System.DirectoryServices.Protocols.LdapSessionOptions.FastConcurrentBind()
  at System.DirectoryServices.AccountManagement.CredentialValidator.BindLdap(NetworkCredential creds, ContextOptions contextOptions)
  at System.DirectoryServices.AccountManagement.CredentialValidator.Validate(String userName, String password)
  at System.DirectoryServices.AccountManagement.PrincipalContext.ValidateCredentials(String userName, String password)
  at (my code)
Run Code Online (Sandbox Code Playgroud)

端口636适用于其他活动,例如查找该LDAP/AD条目的非密码信息...

UserPrincipal.FindByIdentity(pc, IdentityType.SamAccountName, _username)
Run Code Online (Sandbox Code Playgroud)

...所以我知道这不是我的LDAP服务器的SSL设置,因为它适用于其他查找的SSL.

有没有人接到ValidateCredentials(...)通过SSL工作的电话?你能解释一下吗?或者是否有另一种/更好的方法可以安全地验证AD/LDAP凭据?

.net c# directoryservices ldap active-directory

15
推荐指数
1
解决办法
2万
查看次数

如何在.NET中验证LDAP

我想在Windows操作系统上使用任何目录服务验证我的应用程序的用户名和密码.例如,它可以是microsoft active directory,Novell eDirecotry或SunOne.我已经知道如何使用c#本地为Microsoft Active Direcotry执行此代码.(我完全放弃使用ADSI并创建一个低级别的com组件)

尝试使用Novel eDirecotory进行身份验证的方式是我安装了Mono项目.在单声道项目中,它们为您提供Novell.Directory.ldap.dll代码看起来与Microsoft Active Directory相同.(http://www.novell.com/coolsolutions/feature/11204.html)

对于SunOne,我被告知使用与活动目录相同的代码,但是ldap connecton字符串有点不同.(http://forums.asp.net/t/354314.aspx)(http:// technet. microsoft.com/en-us/library/cc720649.aspx)

为了使我的项目复杂化,大多数客户使用"服务帐户:",这意味着我需要使用管理用户名和密码绑定,然后才能验证常规用户名和密码.我的问题分为两部分.

1)根据我上面所解释的,这是我应该针对每个单独的服务进行身份验证的正确方向吗?

2)我觉得我根本不需要做任何这些代码.我也觉得使用服务帐户的规定并不重要.如果我关心的是在Windows机器上验证用户名和密码,为什么我甚至需要使用ldap?我想说的是,考虑一下.当您在早上登录计算机时,您无需提供服务帐户即可登录.我可以通过使用runas功能在DOS提示符下轻松验证用户名和密码,我将被拒绝或无法解析文本文件.我确定还有其他方法可以将用户名和密码传递给我所使用的Windows操作系统,并告诉我用户名和密码是否对其所在的域有效.我对吗?如果是这样,你们有什么建议的方式?

Michael Evanchik www.MikeEvanchik.com

c# novell ldap

13
推荐指数
2
解决办法
4万
查看次数

绑定到Powershell中的其他活动目录ldap实例

我正在尝试连接到一些独立的LDAP存储(ADAM - Active Directory应用程序模式),使用一组特定的凭据进行绑定,但无法确定最佳方法.这是一个我希望可以工作的例子:

$ldapHost = New-Object System.DirectoryServices.DirectoryEntry("LDAP://{serverip}:{port}/dc=acme,dc=com","cn=myuser,dc=acme,dc=com","myPassw0rd")
$ldapQuery = New-Object System.DirectoryServices.DirectorySearcher
$ldapQuery.SearchRoot = $ldapHost
$ldapQuery.Filter = "(objectclass=*)"
$ldapQuery.SearchScope = "Base"
$ldapQuery.FindAll()
Run Code Online (Sandbox Code Playgroud)

这会让我:

Exception calling "FindAll" with "0" argument(s): "A local error has occurred.
"
At line:1 char:19
+ $ldapQuery.FindAll <<<< ()
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException    
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

$ldapHost = New-Object System.DirectoryServices.DirectoryEntry("LDAP://{myip}:{port}/dc=acme,dc=com")
$ldapHost.Username = "cn=myuser,dc=acme,dc=com"
Run Code Online (Sandbox Code Playgroud)

结果如下:

The following exception occurred while retrieving member "Username": "The specified directory            service attribute or valu
e does not …
Run Code Online (Sandbox Code Playgroud)

powershell ldap active-directory

7
推荐指数
1
解决办法
1万
查看次数

从System.DirectoryServices切换到DirectoryServices.Protocols时的身份验证类型

我需要知道AuthenticationTypes中的等效AuthType值,以便从S.DS迁移到S.DS.P代码.

我正在重写当前使用System.DirectoryServices命名空间的LDAP连接模块.为了增加与非ActiveDirectory服务器的兼容性,我试图重写所有代码以使用System.DirectoryServices.Protocols(根据".NET开发人员目录服务编程指南"中的建议).一切顺利,除了使用AuthenticationTypes枚举与SD.Protocols使用的AuthType之间的转换.我需要知道两者之间的等价物,以便使用旧代码的客户端在新代码发布时不会丢失功能.

我所知道的等价物是:
无 - >基本
安全 - >协商(或多或少)
匿名 - >无
SecureSocketsLayer - >将LdapSessionOptions.SecureSocketsLayer设置为true

.net directoryservices ldap active-directory

3
推荐指数
1
解决办法
2051
查看次数