Visual Studio reports that the property does not have a getter, although intellisense says it does

I use the LDAP connection class, working from this page on MSDN .

I instantiated the class using the string constructor as follows:

LdapConnection ld = new LdapConnection("LDAP://8.8.8.8:8888");

Now I want to set my credentials, so I'm trying to do the following:

ld.Credential.UserName = "Foo";

But I get the following error:

The property or indexer 'System.DirectoryServices.Protocols.DirectoryConnection.Credential' cannot be used in this context because it lacks a get accessor.

However, when typing, intellisense shows the following:

enter image description here

This description assumes that UserName really needs to have an Access Accessor, what am I missing?

thank

+3
source share
1 answer

LdapConnection.Credential get, UserName NetworkCredential. LdapConnection.Credential:

ld.Credential = new NetworkCredential(userName, password);

var credential = new NetworkCredential();
credential.UserName = userName;
credential.Password = password;
ld.Credential = credential;

ld.Credential = new NetworkCredential
{
    UserName = userName,
    Password = password,
};
+6

All Articles