<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Active Directory and LDAP</title><link>http://forums.asp.net/93.aspx</link><description>Questions about Active Directory and other directory stores, such as those accessible via LDAP, are appropriate here.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: pb wt Active Directory authentication</title><link>http://forums.asp.net/thread/3316148.aspx</link><pubDate>Tue, 28 Jul 2009 09:18:36 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3316148</guid><dc:creator>tng</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3316148.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=93&amp;PostID=3316148</wfw:commentRss><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;In fact, my authenticate with LDAP works well (not what I thought), just because after the authentication I made another control to find in which group the login belongs to before redirect it to another page &amp;amp; this control doesn&amp;#39;t work. Thanks for your help!&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: pb wt Active Directory authentication</title><link>http://forums.asp.net/thread/3255919.aspx</link><pubDate>Wed, 24 Jun 2009 16:20:25 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3255919</guid><dc:creator>akhhttar</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3255919.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=93&amp;PostID=3255919</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;You are doing one major mistake, You need to understand that ActiveDirectoryMembership Provider and LogonUser() ( The way i wrote in the article) both are alternatives, you can&amp;#39;t use both togather.&lt;/p&gt;&lt;p&gt;Please try http://msdn.microsoft.com/en-us/library/ms998360.aspx to get more understand and How to use ActiverDirectoryMembership Provider.&lt;/p&gt;&lt;p&gt;However there are the answers of your questions,&lt;/p&gt;&lt;p&gt;1. User property would be populated after genrating authentication token. Authentication token can be genrated by FormsAuthentication.RedirectFromLoginPage() OR FormsAuthentication.SetAuthCookie() method, as i discussed in my article.&lt;/p&gt;&lt;p&gt;2. Yes, you can use single welcome page. It all related to your business logic.&lt;/p&gt;&lt;p&gt;3. Yes you can use asp server tags in html markup. like following&lt;/p&gt;&lt;pre style="white-space:pre-wrap;" id="ctl00_MTContentSelector1_mainContentContainer_ctl12CSharp"&gt;&amp;lt;% if (...) %&amp;gt; &lt;br /&gt;&amp;lt;a href= &amp;quot;Employee.aspx&amp;quot;&amp;gt;Gestion des commandes&amp;lt;/a&amp;gt; &lt;br /&gt;&amp;lt;% else %&amp;gt; &lt;br /&gt;&amp;lt;a href= &amp;quot;Employee.aspx&amp;quot;&amp;gt;Gestion des commandes&amp;lt;/a&amp;gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Thanks&lt;br /&gt;Muhammad Akhtar Shiekh&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: pb wt Active Directory authentication</title><link>http://forums.asp.net/thread/3255387.aspx</link><pubDate>Wed, 24 Jun 2009 13:03:43 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3255387</guid><dc:creator>tng</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3255387.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=93&amp;PostID=3255387</wfw:commentRss><description>&lt;p&gt;hello,&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I read the MSDN help but I didn&amp;#39;t understand where to put this code in my prgr&lt;/p&gt;&lt;pre style="white-space:pre-wrap;" id="ctl00_MTContentSelector1_mainContentContainer_ctl12CSharp"&gt;[DirectoryServicesPermissionAttribute(SecurityAction.InheritanceDemand, Unrestricted = &lt;span style="color:blue;"&gt;true&lt;/span&gt;)]&lt;br /&gt;[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]&lt;br /&gt;[DirectoryServicesPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = &lt;span style="color:blue;"&gt;true&lt;/span&gt;)]&lt;br /&gt;[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]&lt;br /&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; ActiveDirectoryMembershipProvider : MembershipProvider&lt;br /&gt;&lt;br /&gt;My web.config is exactly what&amp;#39;s shown in MSDN. In my login.aspx.cs there&amp;#39;s now :&lt;br /&gt;        bool result = LogonUser(userName, domainName, Login1.Password.ToString(), 2, 0, ref token);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (result)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (string.IsNullOrEmpty(Request.QueryString[&amp;quot;ReturnUrl&amp;quot;]))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (User.IsInRole(&amp;quot;Admin&amp;quot;))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Response.Redirect(&amp;quot;WelcomeToAdmin.aspx&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Response.Redirect(&amp;quot;WelcomeToAll.aspx&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;1) The pb is User is empty. I saw that it&amp;#39;s a System.Web.Security.RolePrincipal object, but where is it created? &lt;br /&gt;&lt;br /&gt;2) Instead of using 2 pages WelcomeToAdmin.aspx &amp;amp; WelcomeToAll.aspx with nearly the same content, I&amp;#39;d like to only have one welcome.aspx page:&lt;pre style="white-space:pre-wrap;" id="ctl00_MTContentSelector1_mainContentContainer_ctl12CSharp"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (string.IsNullOrEmpty(Request.QueryString[&amp;quot;ReturnUrl&amp;quot;]))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Response.Redirect(&amp;quot;Welcome.aspx&amp;quot;);&lt;br /&gt;             }&lt;br /&gt;&lt;/pre&gt;And in welcome.aspx:&lt;br /&gt;if (...) { //asp code&lt;br /&gt;&amp;lt;a href= &amp;quot;Employee.aspx&amp;quot;&amp;gt;Gestion des commandes&amp;lt;/a&amp;gt; &amp;lt;!--html code--&amp;gt;&lt;br /&gt;} else { //asp code&lt;br /&gt;&amp;lt;a href= &amp;quot;Employee.aspx&amp;quot;&amp;gt;Gestion des commandes&amp;lt;/a&amp;gt; &amp;lt;!--html code--&amp;gt;&lt;br /&gt;&amp;lt;a href= &amp;quot;Admin.aspx&amp;quot;&amp;gt;Gestion des commandes&amp;lt;/a&amp;gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;3) Is it possible to mix the asp &amp;amp; html code like shown above? (like &amp;lt;script&amp;gt; //code in javascript &amp;lt;/script&amp;gt;)&lt;br /&gt;&lt;br /&gt;Does anyone have the answer? Thank you!!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;</description></item><item><title>Re: pb wt Active Directory authentication</title><link>http://forums.asp.net/thread/3255147.aspx</link><pubDate>Wed, 24 Jun 2009 11:41:35 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3255147</guid><dc:creator>akhhttar</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3255147.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=93&amp;PostID=3255147</wfw:commentRss><description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;HI,&lt;/p&gt;&lt;p&gt;You need to query to Active directory to find out that logged in user is in membership of particular group or not?&lt;/p&gt;&lt;p&gt;Otherwise you can use Active Directory Mebmbership Provider which can do that task for you by using User.IsInRole() method.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;e.g&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;&amp;nbsp;if ( User.IsInRole(&amp;quot;Admin&amp;quot;) )&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;Response.Redirect(&amp;quot;Admin.aspx&amp;quot;);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;else if (User.IsInRole(&amp;quot;Employee&amp;quot;))&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;Response.Redirect(&amp;quot;Employee.aspx&amp;quot;);&lt;/p&gt;&lt;p&gt;
}&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;To learn about Active Directory Membership Provider, please see http://msdn.microsoft.com/en-us/library/system.web.security.activedirectorymembershipprovider.aspx&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Thanks&lt;/p&gt;&lt;p&gt;-Muhammad Akhtar Shiekh&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: pb wt Active Directory authentication</title><link>http://forums.asp.net/thread/3255060.aspx</link><pubDate>Wed, 24 Jun 2009 10:59:31 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3255060</guid><dc:creator>tng</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3255060.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=93&amp;PostID=3255060</wfw:commentRss><description>&lt;p&gt;No, I have for a simple example 3 users in 3 groups: Admin in Admin group, Employee in Emplyee group, Employer in Emplyer group&lt;br /&gt;&lt;/p&gt;&lt;p&gt;from the login page, if the user is authenticated, he&amp;#39;ll be redirected to a welcome page.&lt;/p&gt;&lt;p&gt;In the welcome page, there will be only 3 links: &lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;a href= &amp;quot;Admin management.aspx&amp;quot;&amp;gt;Admin management&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;a href=&amp;quot;Employee management.aspx&amp;quot;&amp;gt;Employee management&amp;lt;/a&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;a href=&amp;quot;Employer management.aspx&amp;quot;&amp;gt;Employer management&amp;lt;/a&amp;gt;&lt;/p&gt;&lt;p&gt;people having Employee rights (group Employee) can only see the link to Employee management page.&lt;/p&gt;&lt;p&gt;peole having Employer rights (group Emplyer) can see both the link to Employee &amp;amp; Employer management pages.&lt;/p&gt;&lt;p&gt;peole having Admin rights (group Admin) can see all the 3 links.&lt;/p&gt;&lt;p&gt;What can I do in welcome page to express this intention?&amp;nbsp; Something like: if (User.Group==&amp;quot;Employee&amp;quot;) {...} else if (User.Group==&amp;quot;Employee&amp;quot;) {} else {}&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: pb wt Active Directory authentication</title><link>http://forums.asp.net/thread/3255006.aspx</link><pubDate>Wed, 24 Jun 2009 10:31:11 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3255006</guid><dc:creator>akhhttar</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3255006.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=93&amp;PostID=3255006</wfw:commentRss><description>&lt;p&gt;FormsAuthentication.RedirectFromLoginPage() is used to redirect the user to the page that he actually requested.&amp;nbsp; &lt;/p&gt;&lt;p&gt;if you always want to redirect the user to welcome page then you
should&amp;nbsp; use FormsAuthentication.SetAuthCookie() method to genrate
authentication token and then redirect the user to different welcome
pages according to the users rights.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Do you want to ask How to check user&amp;#39;s rights? I mean eitehr s/he is part of particular windows group member or not?&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Thanks&lt;/p&gt;&lt;p&gt;Muhammad Akhtar Shiekh&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: pb wt Active Directory authentication</title><link>http://forums.asp.net/thread/3254925.aspx</link><pubDate>Wed, 24 Jun 2009 09:48:02 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3254925</guid><dc:creator>tng</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3254925.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=93&amp;PostID=3254925</wfw:commentRss><description>&lt;p&gt;Thank you akhhttar, you saved me, i&amp;#39;m blocked since 2 days!&lt;/p&gt;&lt;p&gt;Another question:&amp;nbsp; how to determine the FormsAuthentication.RedirectFromLoginPage for my users? I mean: when a user is authenticated (succesfully logged in), they will be redirected to a welcome page in which they can see links to other pages. According to their groups (of rights), they can see less or more links. How can I tell this &amp;quot;welcome&amp;quot; page to hide some links to some groups &amp;amp; show them to others? Thank you very much!&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: pb wt Active Directory authentication</title><link>http://forums.asp.net/thread/3254878.aspx</link><pubDate>Wed, 24 Jun 2009 09:20:31 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3254878</guid><dc:creator>akhhttar</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3254878.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=93&amp;PostID=3254878</wfw:commentRss><description>&lt;p&gt;Please see my latest article on the Windows Authentication using Form Authentication,&lt;/p&gt;&lt;p&gt;http://www.codeproject.com/KB/aspnet/WinAuthusingFormAuth.aspx&lt;/p&gt;&lt;p&gt; It is an easy way to authentication windows user.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Thanks&lt;/p&gt;&lt;p&gt;-Akhtar&lt;br /&gt;&lt;/p&gt;</description></item><item><title>pb wt Active Directory authentication</title><link>http://forums.asp.net/thread/3254783.aspx</link><pubDate>Wed, 24 Jun 2009 08:31:03 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3254783</guid><dc:creator>tng</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3254783.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=93&amp;PostID=3254783</wfw:commentRss><description>&lt;p&gt;&lt;span&gt;hi, i have pb wt Active Directory authentication: 
&lt;br /&gt;
1) 1st try: Membership.GetUser return NULL 
&lt;br /&gt;
2) 2nd try: DirectorySearcher search = new DirectorySearcher(_path);
&lt;br /&gt;
search.Filter = &amp;quot;(cn=&amp;quot; + _filterAttribute + &amp;quot;)&amp;quot;; 
&lt;br /&gt;
search.PropertiesToLoad.Add(&amp;quot;memberOf&amp;quot;);
&lt;br /&gt;
SearchResult result = search.FindOne(); go to catch exception
&lt;br /&gt;
&lt;br /&gt;
S.O can help, pls? Here&amp;#39;s my code:
&lt;br /&gt;
&lt;br /&gt;
1st try :
&lt;br /&gt;
&lt;br /&gt;
protected void LoginButton_Click(object sender, EventArgs e)
&lt;br /&gt;
    {
&lt;br /&gt;
        DirectoryEntry entry = new DirectoryEntry(&amp;quot;LDAP://Media.local/DC=Media, DC=local&amp;quot;, &amp;quot;media\\tng&amp;quot;, &amp;quot;****&amp;quot;); 
&lt;br /&gt;
        object connect = entry.NativeObject;
&lt;br /&gt;
        DirectorySearcher search = new DirectorySearcher(entry);
&lt;br /&gt;
        search.Filter = &amp;quot;(&amp;amp;(objectCategory=user)(SAMAccountName=*))&amp;quot;; 
&lt;br /&gt;
        search.PropertiesToLoad.Add(&amp;quot;cn&amp;quot;);
&lt;br /&gt;
        foreach (SearchResult result in search.FindAll())
&lt;br /&gt;
        {
&lt;br /&gt;
            DirectoryEntry dirEntry = result.GetDirectoryEntry(); 
&lt;br /&gt; string login = (dirEntry.Properties[&amp;quot;SAMAccountName&amp;quot;].Value !=
null) ? dirEntry.Properties[&amp;quot;SAMAccountName&amp;quot;].Value.ToString() :
String.Empty;
&lt;br /&gt;
            string name = (dirEntry.Properties[&amp;quot;sn&amp;quot;].Value != null) ? dirEntry.Properties[&amp;quot;sn&amp;quot;].Value.ToString() : String.Empty;
&lt;br /&gt; string surname = (dirEntry.Properties[&amp;quot;givenName&amp;quot;].Value != null)
? dirEntry.Properties[&amp;quot;givenName&amp;quot;].Value.ToString() : String.Empty;
&lt;br /&gt; string tel = (dirEntry.Properties[&amp;quot;TelephoneNumber&amp;quot;].Value !=
null) ? dirEntry.Properties[&amp;quot;TelephoneNumber&amp;quot;].Value.ToString() :
String.Empty;
&lt;br /&gt; string email = (dirEntry.Properties[&amp;quot;mail&amp;quot;].Value != null) ?
dirEntry.Properties[&amp;quot;mail&amp;quot;].Value.ToString() : String.Empty;
&lt;br /&gt;
            string path = result.Path;
&lt;br /&gt;
            string filterAttribute = (String)result.Properties[&amp;quot;cn&amp;quot;][0];
&lt;br /&gt;
            if (String.Compare(login, 0, &amp;quot;tng&amp;quot;, 0, 3, true) == 0)
&lt;br /&gt;
            {
&lt;br /&gt;
                lErreur.Text = &amp;quot; login=&amp;quot; + login + &amp;quot; name=&amp;quot; + name + &amp;quot; surname=&amp;quot; + surname + &amp;quot; tel=&amp;quot; + tel + &amp;quot; email=&amp;quot; + email;
&lt;br /&gt;
                if (Request.LogonUserIdentity.IsAuthenticated)
&lt;br /&gt;
                	lErreur.Text += &amp;quot; Request.LogonUserIdentity.IsAuthenticated=&amp;quot; + Request.LogonUserIdentity.Name;
&lt;br /&gt;
&lt;br /&gt;
                lErreur.Text += &amp;quot; User.Identity.IsAuthenticated=&amp;quot; + User.Identity.IsAuthenticated;
&lt;br /&gt;// the debug skips the if case. In the label: login=TNG name=NGO
surname=Thanh tel=01 00 00 00 00 email=thanh.ngo@media.com
User.Identity.IsAuthenticated=False
&lt;br /&gt;
&lt;br /&gt;
                MembershipUser u = Membership.GetUser(Login1.UserName); //Login1.UserName=”tng”
&lt;br /&gt;
                if (u == null) //u=null. WHY???
&lt;br /&gt;
                {
&lt;br /&gt;
                    Login1.FailureText = &amp;quot;Invalid user name. Please check your user name and try again.&amp;quot;;
&lt;br /&gt;
                    return;
&lt;br /&gt;
                }
&lt;br /&gt;
                if (Membership.ValidateUser(Login1.UserName.ToString(), Login1.Password.ToString()))
&lt;br /&gt;
                {
&lt;br /&gt;
                    FormsAuthentication.RedirectFromLoginPage(Login1.UserName.ToString(), false);
&lt;br /&gt;
                    HttpContext.Current.Session[&amp;quot;username&amp;quot;] = Login1.UserName.ToString();
&lt;br /&gt;
                    Response.Redirect(&amp;quot;Welcome.aspx&amp;quot;,false);
&lt;br /&gt;
                }
&lt;br /&gt;
                else
&lt;br /&gt;
                    Login1.FailureText = &amp;quot;Invalid password. Please check your password and try again.&amp;quot;;
&lt;br /&gt;
                break;
&lt;br /&gt;
            }
&lt;br /&gt;
        }
&lt;br /&gt;
    }
&lt;br /&gt;
&lt;br /&gt;
2nd try: I clear all &amp;amp; try the method proposed by msdn:
&lt;br /&gt;
&lt;br /&gt;
public partial class Identification : System.Web.UI.Page
&lt;br /&gt;
{
&lt;br /&gt;
    private string _path;
&lt;br /&gt;
    private string _filterAttribute;
&lt;br /&gt;
    public Identification(string path)
&lt;br /&gt;
    {
&lt;br /&gt;
      _path = path;
&lt;br /&gt;
    }
&lt;br /&gt;
    public bool IsAuthenticated(string domain, string username, string pwd)
&lt;br /&gt;
    {
&lt;br /&gt;
      string domainAndUsername = domain + username; 
&lt;br /&gt;
      DirectoryEntry entry = new DirectoryEntry( _path, domainAndUsername, pwd);
&lt;br /&gt;
      try
&lt;br /&gt;
      { 
&lt;br /&gt;
        Object obj = entry.NativeObject;
&lt;br /&gt;
        DirectorySearcher search = new DirectorySearcher(entry);
&lt;br /&gt;
        search.Filter = &amp;quot;(SAMAccountName=&amp;quot; + username + &amp;quot;)&amp;quot;;
&lt;br /&gt;
        search.PropertiesToLoad.Add(&amp;quot;cn&amp;quot;);
&lt;br /&gt;
        SearchResult result = search.FindOne();
&lt;br /&gt;
        if(null == result)
&lt;br /&gt;
        {
&lt;br /&gt;
          return false;
&lt;br /&gt;
        }
&lt;br /&gt;
        _path = result.Path;
&lt;br /&gt;
        _filterAttribute = (String)result.Properties[&amp;quot;cn&amp;quot;][0];
&lt;br /&gt;
      }
&lt;br /&gt;
      catch (Exception ex)
&lt;br /&gt;
      {
&lt;br /&gt;
        throw new Exception(&amp;quot;Error authenticating user. &amp;quot; + ex.Message);
&lt;br /&gt;
      }
&lt;br /&gt;
      return true;
&lt;br /&gt;
    }
&lt;br /&gt;
    public string GetGroups()
&lt;br /&gt;
    {
&lt;br /&gt;
      DirectorySearcher search = new DirectorySearcher(_path);
&lt;br /&gt;
      search.Filter = &amp;quot;(cn=&amp;quot; + _filterAttribute + &amp;quot;)&amp;quot;; //search.filter=”Thanh NGO”
&lt;br /&gt;
      search.PropertiesToLoad.Add(&amp;quot;memberOf&amp;quot;);
&lt;br /&gt;
      StringBuilder groupNames = new StringBuilder();
&lt;br /&gt;
      try
&lt;br /&gt;
      {
&lt;br /&gt;
        SearchResult result = search.FindOne(); //aller dans catch(exception ex). Pourquoi???
&lt;br /&gt;
        int propertyCount = result.Properties[&amp;quot;memberOf&amp;quot;].Count;
&lt;br /&gt;
        String dn;
&lt;br /&gt;
        int equalsIndex, commaIndex;
&lt;br /&gt;
        for( int propertyCounter = 0; propertyCounter &amp;lt; propertyCount; propertyCounter++)
&lt;br /&gt;
        {
&lt;br /&gt;
          dn = (String)result.Properties[&amp;quot;memberOf&amp;quot;][propertyCounter];
&lt;br /&gt;
          equalsIndex = dn.IndexOf(&amp;quot;=&amp;quot;, 1);
&lt;br /&gt;
          commaIndex = dn.IndexOf(&amp;quot;,&amp;quot;, 1);
&lt;br /&gt;
          if (-1 == equalsIndex)
&lt;br /&gt;
          {
&lt;br /&gt;
            return null;
&lt;br /&gt;
          }
&lt;br /&gt;
          groupNames.Append(dn.Substring((equalsIndex + 1),  (commaIndex - equalsIndex) - 1));
&lt;br /&gt;
        groupNames.Append(&amp;quot;|&amp;quot;);
&lt;br /&gt;
        }
&lt;br /&gt;
      }
&lt;br /&gt;
      catch(Exception ex)
&lt;br /&gt;
      {
&lt;br /&gt;
        throw new Exception(&amp;quot;Error obtaining group names. &amp;quot; + ex.Message);
&lt;br /&gt;
      } 
&lt;br /&gt;
      return groupNames.ToString();
&lt;br /&gt;
    }
&lt;br /&gt;
protected void  LoginButton_Click(object sender, EventArgs e)
&lt;br /&gt;
    {
&lt;br /&gt;
        string adPath = &amp;quot;LDAP://Media.local/DC=Media,DC=local&amp;quot;; 
&lt;br /&gt;
        Identification adAuth = new Identification(adPath);
&lt;br /&gt;
        try
&lt;br /&gt;
        {
&lt;br /&gt;
            if (true == adAuth.IsAuthenticated(&amp;quot;Media\\&amp;quot;,
&lt;br /&gt;
                     Login1.UserName.ToString(),Login1.Password.ToString())) 
&lt;br /&gt;
          {
&lt;br /&gt;
             string groups = adAuth.GetGroups(); //aller dans catch(exception ex).Regarde fct
&lt;br /&gt;
//GetGroups() en haut
&lt;br /&gt;
            FormsAuthenticationTicket authTicket = 
&lt;br /&gt; new FormsAuthenticationTicket(1,
Login1.UserName.ToString(),DateTime.Now,
DateTime.Now.AddMinutes(60),false, groups);
&lt;br /&gt;
            string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
&lt;br /&gt;
            HttpCookie authCookie = new Cookie(FormsAuthentication.FormsCookieName,
&lt;br /&gt;
                                        encryptedTicket);
&lt;br /&gt;
            Response.Cookies.Add(authCookie); 
&lt;br /&gt;
      Response.Redirect(&amp;quot;Welcome.aspx&amp;quot;,false)Response.Redirect(&amp;quot;Welcome.aspx&amp;quot;,false); 
&lt;br /&gt;
   }
&lt;br /&gt;
          else
&lt;br /&gt;
          {
&lt;br /&gt;
            lErreur.Text = 
&lt;br /&gt;
                 &amp;quot;Authentication failed, check username and password.&amp;quot;;
&lt;br /&gt;
          }
&lt;br /&gt;
        }
&lt;br /&gt;
        catch(Exception ex)
&lt;br /&gt;
        {
&lt;br /&gt;
          lErreur.Text = &amp;quot;Error authenticating. &amp;quot; + ex.Message;
&lt;br /&gt;
        }
&lt;br /&gt;
    }
&lt;br /&gt;
}
&lt;br /&gt;
&lt;br /&gt;
here&amp;#39;s my web.config for both try:
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot;?&amp;gt;
&lt;br /&gt;
&amp;lt;configuration&amp;gt;
&lt;br /&gt;
&amp;lt;connectionStrings&amp;gt;
&lt;br /&gt;
    		&amp;lt;add name=&amp;quot;ADMedia&amp;quot; connectionString=&amp;quot;LDAP://Media&amp;quot;/&amp;gt;  
&lt;br /&gt;
    	&amp;lt;/connectionStrings&amp;gt;
&lt;br /&gt;
	&amp;lt;system.web&amp;gt;
&lt;br /&gt;
		&amp;lt;authentication mode=&amp;quot;Forms&amp;quot;&amp;gt;
&lt;br /&gt;
      		&amp;lt;forms loginUrl=&amp;quot;login.aspx&amp;quot; path=&amp;quot;/&amp;quot; requireSSL=&amp;quot;false&amp;quot;
&lt;br /&gt;
cookieless=&amp;quot;UseDeviceProfile&amp;quot; enableCrossAppRedirects=&amp;quot;false&amp;quot;
&lt;br /&gt;
             	protection=&amp;quot;All&amp;quot; domain=http://Media name=&amp;quot;.ASPXFORMSAUTH&amp;quot;&amp;gt;
&lt;br /&gt;
      		&amp;lt;/forms&amp;gt; 
&lt;br /&gt;
		&amp;lt;/authentication&amp;gt;
&lt;br /&gt;
&amp;lt;membership defaultProvider=&amp;quot;AspNetActiveDirectoryMembershipProvider&amp;quot; &amp;gt;
&lt;br /&gt;
	&amp;lt;providers&amp;gt;
&lt;br /&gt;
        &amp;lt;remove name=&amp;quot;AspNetActiveDirectoryMembershipProvider&amp;quot;/&amp;gt;
&lt;br /&gt; &amp;lt;add connectionStringName=&amp;quot;ADMedia&amp;quot;
connectionUsername=&amp;quot;media\tng&amp;quot; connectionPassword=&amp;quot;****&amp;quot;
name=&amp;quot;AspNetActiveDirectoryMembershipProvider&amp;quot;
type=&amp;quot;System.Web.Security.ActiveDirectoryMembershipProvider,System.Web,version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a&amp;quot;/&amp;gt;
&lt;br /&gt;
      &amp;lt;/providers&amp;gt;
&lt;br /&gt;
	&amp;lt;/membership&amp;gt;
&lt;br /&gt;
&amp;lt;roleManager enabled=&amp;quot;true&amp;quot;/&amp;gt;
&lt;br /&gt;
    	&amp;lt;anonymousIdentification enabled=&amp;quot;true&amp;quot;/&amp;gt;
&lt;br /&gt;
…
&lt;br /&gt;
&lt;br /&gt;Média is a Outlook LDAP (wich is in another pc &amp;amp; linked to mine
by intranet) where there&amp;#39;s every information (name, surname, email,
tel, group, @pc). &lt;br /&gt;
I configured IIS like this : in directory security :
&lt;br /&gt;
-	check Anonymous Connection 
&lt;br /&gt;
-	uncheck Authorise psw verification by IIS
&lt;br /&gt;
-	check base authentification, default domain : Media, domain: Media.local
&lt;br /&gt;
-	check  window integreted authentification 
&lt;br /&gt;
&lt;br /&gt;
I can&amp;#39;t connect to management of ASP.NET via SiteWeb menu in
VisualStudio2008. Error: “Provider Management Could not establish a
connection to the database. If you have not yet created the SQL Server
database, exit the Web Site Administration tool, use the aspnet_regsql
command-line utility to create and configure the database, and then
return to this tool to set the provider.”
&lt;br /&gt;
&lt;br /&gt;
I executed aspnet_regsql from the command line, nothing changed. What else I have to do? Thank you for your help&lt;/span&gt;&lt;/p&gt;</description></item></channel></rss>