简体   繁体   English

如何在.net C#中使用ldap

[英]How to work with ldap in .net C#

I have an application where i can send emails. 我有一个可以发送电子邮件的应用程序。 Now am asked to use ldap in to and from fields of the email.Am very new to this concept. 现在被要求在电子邮件的字段中使用ldap,这对这个概念是非常新的。 I have been given a ldap link. 我得到了一个ldap链接。 No idea how to proceed with that. 不知道该如何进行。 Any aricle or hits will be greatly helpful. 任何文章或热门歌曲都将非常有帮助。

If you're on .NET 3.5 and up and using Microsoft's Active Directory as your LDAP store, you should check out the System.DirectoryServices.AccountManagement (S.DS.AM) namespace. 如果您使用的是.NET 3.5及更高版本,并且使用Microsoft的Active Directory作为LDAP存储,则应检出System.DirectoryServices.AccountManagement (S.DS.AM)命名空间。 Read all about it here: 在这里阅读所有内容:

Basically, you can define a domain context and easily find users and/or groups in AD: 基本上,您可以定义域上下文并轻松找到AD中的用户和/或组:

// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);

// find a user
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName");

if(user != null)
{
   // do something here, e.g. get the user's e-mail address(es)
}

The new S.DS.AM makes it really easy to play around with users and groups in AD! 新的S.DS.AM使得与AD中的用户和组玩起来非常容易!

Most of the functionality I've used is in System.DirectoryServices. 我使用的大多数功能都在System.DirectoryServices中。

Have a look at this link for more info: http://lozanotek.com/blog/articles/149.aspx 请查看此链接以获取更多信息: http : //lozanotek.com/blog/articles/149.aspx

The LDAP link is basically a reference to a directory server, such as Active Directory, which will give you email addresses if you have their user name, for example. LDAP链接基本上是对目录服务器(例如Active Directory)的引用,例如,如果具有用户名,则将为您提供电子邮件地址。 I'd start off by reading the article above, then experimenting with a small test program 我将从阅读上面的文章开始,然后尝试一个小的测试程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM