LDAP Client.Net

AttributeCollection.Exists Method 

Checks if an attribute exists in the collection. Attribute name is case-sensitive.

[Visual Basic]
MustOverride Public Function Exists( _ 
   ByVal attributeName As String _ 
) As Boolean
[C#]
public abstract bool Exists(
   string attributeName
);
[C++]
public: abstract bool Exists(
   String* attributeName
);
[JScript]
public abstract function Exists(
   String attributeName
): bool;

Parameters

attributeName
Attribute name to check for.

Return Value

true if attribute exists; otherwise false.

Example

[C#]
using System;
using LdapServices.Ldap;

namespace LDAPSampleCodeConsole
{
class SampleApp
{
static void Main(string[] args)
{
Client client = new Client();

// Connect to the directory
client.Connect("directory.yourServer.ca");
// Search the directory for entries with surname starting with 'Ab'
EntryCollection entries = client.Search("o=yourCompany,c=ca", "sn=Ab*");

// Does the cn Attribute exist?
AttributeCollection attributes = entries[0].Attributes;
Console.WriteLine("cn attribute Exists: " + attributes.Exists("cn"));

client.Disconnect();
}
}
}

See Also

AttributeCollection Class | LdapServices.Ldap Namespace