![]() |
Languages »
C# »
General
Beginner
License: The Code Project Open License (CPOL)
Lightweight Directory Access Protocol Uniform Resource Identifier (LDAPUri)By Paw JershaugeAn Attempt to make Uniform resource identifier for the Lightweight Directory Access Protocol |
C# (C#1.0, C#2.0, C#3.0), Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
This is an attempt to make a Uniform Resource Identifier for the Lightweight Directory Access Protocol (LDAP).
While working with DirectoryEntry, I encountered some errors due to the LDAP Path. So I decided to make an attempt to create a Uniform Resource Identifier for the LDAP path.
Using the LDAPUri class is straight forward.
The following code demonstrates building an LDAP path part-wise:
LDAPUri LDAPUriTest = new LDAPUri();
LDAPUriTest.Protocol = LDAPProtocol.LDAP;
LDAPUriTest.Attributes.Add(new LDAPAttribute
(LDAPAttributeType.CommonNames, "Computers"));
LDAPUriTest.Attributes.Add(new LDAPAttribute(LDAPAttributeType.DomainComponent, "www"));
LDAPUriTest.Attributes.Add(new LDAPAttribute
(LDAPAttributeType.DomainComponent, "codeproject"));
LDAPUriTest.Attributes.Add(new LDAPAttribute(LDAPAttributeType.DomainComponent, "com"));
The above code returns the following:
LDAPUriTest.Port - 389LDAPUriTest.Protocol - LDAPProtocol.LDAPLDAPUriTest.LDAPPathShort - CN=Computers,DC=www,DC=codeproject,DC=comLDAPUriTest.LDAPPath - LDAP://CN=Computers,DC=www,DC=codeproject,DC=comThe following code demonstrates building an LDAP path by throwing the string direct into the LDAPUri Class constructor:
LDAPUri LDAPUriTest = new LDAPUri(LDAP://CN=Computers,DC=www,DC=codeproject,DC=com);
or:
LDAPUri LDAPUriTest = new LDAPUri("CN=Computers,DC=www,DC=codeproject,DC=com");
The above code returns the following:
LDAPUriTest.Port - 389LDAPUriTest.Protocol - LDAPProtocol.LDAPLDAPUriTest.LDAPPathShort - CN=Computers,DC=www,DC=codeproject,DC=comLDAPUriTest.LDAPPath - LDAP://CN=Computers,DC=www,DC=codeproject,DC=comWhen using the LDAPUri, the Path will be validated and will always be returned correctly.
Root to Host Port property
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+PgUp/PgDown to switch pages.
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 28 Feb 2008 Editor: Deeksha Shenoy |
Copyright 2008 by Paw Jershauge Everything else Copyright © CodeProject, 1999-2010 Web09 | Advertise on the Code Project |