.NET LDAP OpenDS的阅读习惯属性0x8000500c属性、习惯、LDAP、NET

2023-09-05 00:51:52 作者:撩人妖精

我想建立一个功能,我的.NET应用程序将能够与LDAP服务器来读取用户属性和用户进行身份验证。我已经安装使用OpenDS的测试目录服务器,添加了自定义属性和对象,并添加用户提供新的对象类型。一切工作正常,直到我尝试读取自定义属性值,我得到:

I'm trying to build a feature to my .Net application to be able to talk to an LDAP server to read user attributes and authenticate users. I have setup a test directory server using OpenDS, added custom attributes and objects, and added users with the new object types. Everything works fine until I attempt to read the custom attribute values, I get :

{"Unknown error (0x8000500c)"}
at System.DirectoryServices.PropertyValueCollection.PopulateList()
at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)

我试图从this帖子(使用正确形成的OID),以及this帖子(使用完全合格的域名在LDAP路径 - 我使用的东西,如LDAP://mymachine.company.local / ...)。 其他人则建议,由于COM错误code意味着E_ADS_CANT_CONVERT_DATATYPE有什么不对我的属性或模式,但属性设置为DirectoryString,其中也有其他默认领域同一类型,我可以读。

I have tried suggestions from this post (using properly formed oids) as well as this post (using fully qualified domain name in your ldap path - i am using something like LDAP://mymachine.company.local/... ). Others have suggested that since the COM error code means E_ADS_CANT_CONVERT_DATATYPE there is something wrong with my attributes or schema, but the attributes are setup as DirectoryString, which there are other default fields of the same type that I can read.

我明白与OpenDS的工作将无法正常工作的A​​ctive Directory,我对广告的是工作的罚款单独的模块一样,我只是想知道如果任何人有经验,交谈和OpenDS或Sun的一个LDAP实现。

I understand working with OpenDS will not work the same as Active Directory, I have a separate module for AD that is working fine, I'm just wondering if anyone has had experience with talking to OpenDS or Sun One LDAP implementations.

思考?我找不到太多关于谷歌与OpenDS的和.NET一起处理这让我觉得我应该做别的事情。正如我说,这个广告的东西正常工作,但是我真的希望能够做到这一点与OpenDS的为好。

Thoughts? I can't find much on google dealing with OpenDS and .NET together which makes me think I should be doing something else. As I said the AD stuff works fine however I'd really like to be able to do this with OpenDS as well.

谢谢!

生锈

推荐答案

我有这个错误试图读取从Linux OpenLDAP的数据库中的多值的字符串。

I had this error trying to read a multi-value string from a linux OpenLdap database.

这似乎是一个错误,因为我发现在XP和Server 2003时出现错误,但在Windows 7相同的code和Server 2008中返回安装了.NET版本的价值,而不管。

It seems like a bug as I found the error occurs on XP and Server 2003, but the same code on Windows 7 and Server 2008 returns the values, regardless of .NET versions installed.

不过,我发现了一个变通的C#中使用一个更直接地访问。除了Directory.Services,你将需要添加引用,COM,活动DS类型库。

However I found a work-around for C# using a more direct access. In addition to Directory.Services, you will need to add the reference, COM, 'Active DS Type Library'.

var dirEntry = new DirectoryEntry("ldapDn", "logonDn", "logonPass");
var nativeEntry = (ActiveDs.IADsPropertyList)dirEntry.NativeObject;
var propEntry = (ActiveDs.IADsPropertyEntry)nativeEntry.GetPropertyItem("attributeName", 3);
foreach (ActiveDs.IADsPropertyValue propValue in (object[])propEntry.Values)
{
    Debug.Print(propValue.CaseIgnoreString);
}

这是放在一起为自己的简单的需求,这里是作为参考,也是的 AdsType枚举。

This was put together for my own simple needs, here is the full helper class used as a reference and also the AdsType Enums.