Website is not able to connect to Active Directoryhttp://forums.asp.net/t/1559361.aspx/1?Website+is+not+able+to+connect+to+Active+DirectoryTue, 18 May 2010 18:05:20 -040015593613845722http://forums.asp.net/p/1559361/3845722.aspx/1?Website+is+not+able+to+connect+to+Active+DirectoryWebsite is not able to connect to Active Directory <p>Hi All,</p> <p>&nbsp;</p> <p>I have done a small active directory application and it is working fine&nbsp;in my testing environment. However, When&nbsp;I put it on the production server, it is throwing following erro</p> <p>Main Error: <i>Logon failure: unknown user name or bad password.<br> </i></p> <p>Stack&nbsp;Trace&nbsp;:[DirectoryServicesCOMException (0x8007052e): Logon failure: unknown user name or bad password.<br> ]<br> &nbsp;&nbsp; System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) &#43;636<br> &nbsp;&nbsp; System.DirectoryServices.DirectoryEntry.Bind() &#43;36<br> &nbsp;&nbsp; System.DirectoryServices.DirectoryEntry.get_AdsObject() &#43;31<br> &nbsp;&nbsp; System.DirectoryServices.PropertyValueCollection.PopulateList() &#43;25<br> &nbsp;&nbsp; System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) &#43;93<br> &nbsp;&nbsp; System.DirectoryServices.PropertyCollection.get_Item(String propertyName) &#43;132<br> &nbsp;&nbsp; IntranetApps.ContactInfo.Button1_Click(Object sender, EventArgs e) in C:\Work\IntranetApps\IntranetApps\contact_info.aspx.vb:846<br> &nbsp;&nbsp; System.Web.UI.WebControls.Button.OnClick(EventArgs e) &#43;104<br> &nbsp;&nbsp; System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) &#43;107<br> &nbsp;&nbsp; System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) &#43;7<br> &nbsp;&nbsp; System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) &#43;11<br> &nbsp;&nbsp; System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) &#43;33<br> &nbsp;&nbsp; System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) &#43;5614<br> </p> <p>&nbsp;</p> <p>1.) I am able to ping the mail server (where active directory is in) and can map a drive</p> <p>2.) The webserver is in the VM ware</p> <p>3.)I am using directory service logging method to connect as following</p> <pre class="prettyprint">Dim RootDSE As New DirectoryServices.DirectoryEntry(&quot;LDAP://0.0.0.111/rootDSE&quot;) Dim DomainDistinguishedName As String = RootDSE.Properties(&quot;DefaultNamingContext&quot;).Value Dim ADEntry As New DirectoryServices.DirectoryEntry(&quot;LDAP://0.0.0.111/ou=abcd Employees,&quot; &amp; DomainDistinguishedName) ADEntry.Username = &quot;administrator&quot; ADEntry.Password = &quot;abcdef</pre> <p><br> Is there any problem with my coding to connect? Please help me on this</p> 2010-05-18T13:55:26-04:003846237http://forums.asp.net/p/1559361/3846237.aspx/1?Re+Website+is+not+able+to+connect+to+Active+DirectoryRe: Website is not able to connect to Active Directory <p>Finally, I managed to&nbsp;find the solution by myself </p> <p>&nbsp;</p> <p>This is the code</p> <pre class="prettyprint">Dim RootDSE As New DirectoryServices.DirectoryEntry(&quot;LDAP://mail.local.abcdefgh.com/rootDSE&quot;, &quot;user&quot;, &quot;pwd&quot;, AuthenticationTypes.Secure) Dim DomainDistinguishedName As String = RootDSE.Properties(&quot;DefaultNamingContext&quot;).Value Dim ADEntry As New DirectoryServices.DirectoryEntry(&quot;LDAP://mail.local.abcdefgh.com/rootDSE,&quot; &amp; DomainDistinguishedName) ADEntry.Username = &quot;user&quot; ADEntry.Password = &quot;pwd&quot;</pre> <p><br> All I added is AuthenticationType.secure and user login details. Apart from this I&nbsp;added &quot;&lt;identity impersonate=&quot;true&quot;/&gt;&quot; in my web.config file</p> <p>&nbsp;</p> 2010-05-18T18:05:20-04:00