使用.NET DirectoryServices获取原始属性值

时间:2011-02-18 21:55:43

标签: c# directoryservices edirectory

有谁知道是否有可能获得任何LDAP对象属性X的值?似乎.NET或ADSI删除了无法处理的东西(de.Properties.Values.Count == de.Properties.PropertyNames.Count> de.Properties.Values.props.valueTable.Count)。

        binddn.Text = "cn=admin,o=system";
        bindpass.Password = "XXXXX";
        server.Text = "10.X.X.X";
        basedn.Text = "cn=server,o=system";
        StringBuilder basepath = new StringBuilder("LDAP://");
        basepath.Append(server.Text).Append("/").Append(basedn.Text);

        DirectoryEntry myDirectoryEntry = new DirectoryEntry(basepath.ToString());
        myDirectoryEntry.Username = binddn.Text;
        myDirectoryEntry.Password = bindpass.Password;
        myDirectoryEntry.AuthenticationType = AuthenticationTypes.ServerBind;

        foreach (string key in myDirectoryEntry.Properties.PropertyNames)
        {
            object val = myDirectoryEntry.Properties[key].Value;

        }

这会在networkAddress属性上崩溃,这是二进制字段(http://ldapwiki.willeke.com/wiki/Ldapsearch%20Networkaddress)。

0 个答案:

没有答案