Visual Studio reports that property has no getter, even though intellisense says it does
c#, ldap
Solution
The LdapConnection.Credential Property doesn't have a `get` accessor, so you can't retrieve its current value and set the `UserName` property on the returned NetworkCredential instance. You can only assign to the LdapConnection.Credential Property:
ld.Credential = new NetworkCredential(userName, password);
or
var credential = new NetworkCredential();
credential.UserName = userName;
credential.Password = password;
ld.Credential = credential;
or
ld.Credential = new NetworkCredential
{
UserName = userName,
Password = password,
};
Problem
I am using the LDAP connection class, working from this page on MSDN. I have instantiated the class using the string constructor like so: ``` LdapConnection ld = new LdapConnection("LDAP://8.8.8.8:8888"); ``` I now want to set my credentials so I am 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 the get accessor. However, when typing this, intellisense shows the following: This description suggests that UserName should indeed have a Get Accessor, what am I missing? Thanks