TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Vaibhav Deshmukh
NA
465
73.7k
LDAP Authentication
Feb 27 2017 7:03 AM
Hi,
I am badly stucked in implementing LDAP Authentication.
My moto is to find OU or(Groups) based on Username.Means find a particular group for user based on Username.I am trying below way but not getting what I expecting.Since, my credentials are valid it throws an exception "The user name or password is incorrect.":
Snap 1:
DirectoryEntry entry =
new
DirectoryEntry(
"LDAP://IP Address:Port/CN=Users,DC=domain,DC=com"
,username,password);
DirectorySearcher ds =
new
DirectorySearcher(entry);
ds.Filter =
"(&(objectClass=user)(cn="
+ username +
"))"
;
SearchResult results = ds.FindOne();
Snap 2 :
The below code snippet works fine but it only confirms Authentication for me:
using
(LdapConnection ldap =
new
LdapConnection(ConfigurationManager.ConnectionStrings[
"ADConnectionString"
].ConnectionString))
{
ldap.AuthType = AuthType.Basic;
ldap.SessionOptions.ProtocolVersion = 3;
// Distinguished name is reuired to pass to the bind method
string
distinguishedName =
"cn="
+ username +
",ou=Users,dc=domain,dc=com"
;
ldap.Bind(
new
NetworkCredential(distinguishedName, password));
}
Please Correct Me ! As I am New to LDAP I don't know whats the replacement code for above
circumstance
.
1.
Can I use any LDAP conection object or property so that I need not create any DirectoryEntry parameter (String Path,String Username,String password) ?
2.
I have pair of two credentials set. One for Connection string to LDAP server and second one is for user. I tried both . But didn't find any way out.
3
. How to create connection string for LDAP or DirectoryEntry as connection parameter.?
Thanks In advance.
Reply
Answers (
6
)
Can i setup ldap server with ssl certificate?
How to setup AD in Azure?