Obtaining raw property value with .NET DirectoryServices
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 ).
精彩评论