开发者

Obtaining raw property value with .NET DirectoryServices

开发者 https://www.devze.com 2023-02-12 13:10 出处:网络
Does anyone know if it\'s possible to get value of any LDAP object\'s property X? It seems like that .NET or ADSI removes stuff it cannot handle (de.Properties.Values.Count == de.Properties.PropertyNa

Does anyone know if it's possible to get value of any LDAP object's property X? It seems like that .NET or ADSI removes stuff it cannot handle (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.Au开发者_运维技巧thenticationType = AuthenticationTypes.ServerBind;

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

        }

This crashes on networkAddress property which is binary field ( http://ldapwiki.willeke.com/wiki/Ldapsearch%20Networkaddress ).

0

精彩评论

暂无评论...
验证码 换一张
取 消