On 12 Oct, 10:43, "teeja...@gmail.com" <teeja...@gmail.com> wrote:
> > <teeja...@gmail.com> wrote in message
>
[quoted text clipped - 10 lines]
>
> I have added the reference to the project.
i get the following error
Server Error in '/StripNET' Application.
Runtime Error
Description: An application error occurred on the server. The current
custom error settings for this application prevent the details of the
application error from being viewed remotely (for security reasons).
It could, however, be viewed by browsers running on the local server
machine.
if i remove the part using directory services it runs without an error.
Mark Rae [MVP] - 12 Oct 2007 11:31 GMT
>> I have added the reference to the project.
>
> i get the following error
>
> Server Error in '/StripNET' Application.
Then there's either a bug in your code somewhere, or you're not using
Windows 2003...
Presumably your code looks something like this:
http://en.csharp-online.net/User_Management_with_Active_Directory%E2%80%94Determ
ining_Account_Lockout
How are you actually referencing the User object...?

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
teejayem@gmail.com - 12 Oct 2007 11:50 GMT
> <teeja...@gmail.com> wrote in message
>
[quoted text clipped - 16 lines]
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net
No, the code works fine. It works fine on my PC which is running
IIS. Even if I am browsing to it out of VS. But if any other user
tried to use it on their machine it throws up the error. If i remove
this code that checks if the account is locked out then other users
don't receive the error.
my code is as follows:-
imports system.directoryservices
' some code above here which is not causing the problem.
Dim objUser As New DirectoryEntry("LDAP://" & strLDAP)
Dim objSearcher As DirectorySearcher = New
DirectorySearcher(objUser)
Dim objResults As SearchResultCollection
Dim objResult As SearchResult
Const lockoutFlag As Integer = 16
objSearcher.PropertiesToLoad.Add("msds-User-Account-Control-
Computed")
objResults = objSearcher.FindAll()
For Each objResult In objResults
Dim status As Integer =
DirectCast(objResult.Properties("msds-User-Account-Control-Computed")
(0), Integer)
If (status And lockoutFlag) = lockoutFlag Then
IsAccountLocked = True
Session("LDAP") = strLDAP
Else
IsAccountLocked = False
End If
Next
objUser.Close()
objUser.Dispose()
thanks for your help by the way. I really appreciate it!
Mark Rae [MVP] - 12 Oct 2007 12:33 GMT
>> <teeja...@gmail.com> wrote in message
>>
[quoted text clipped - 57 lines]
>
> thanks for your help by the way. I really appreciate it!

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
Mark Rae [MVP] - 12 Oct 2007 12:35 GMT
> No, the code works fine. It works fine on my PC which is running
> IIS. Even if I am browsing to it out of VS. But if any other user
> tried to use it on their machine it throws up the error. If i remove
> this code that checks if the account is locked out then other users
> don't receive the error.
As I mentioned a couple of replies back, the user under which ASP.NET runs
by default doesn't have sufficient privileges to query ActiveDirectory, so
you will need to set up impersonation. Pretty much any standard DomainUser
account will do unless you need to make changes to AD objects...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
teejayem@gmail.com - 12 Oct 2007 13:45 GMT
> <teeja...@gmail.com> wrote in message
>
[quoted text clipped - 14 lines]
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net
Yes that seemed to be the problem.
Although my IIS is set up to use Windows Authentication.
I have set my web site up for <identity impersonation=True />
Still didn't work.
I have to explicitly add the userName and Password attributed to the
identity element tag for it to work. I was under the impression that
impersonation should run as the user that the IIS session is running
as. If I am using Windows Authentication this should be the user who
is viewing the website, true? Well these users definatly have
sufficient privilages.
Mark Rae [MVP] - 12 Oct 2007 17:17 GMT
> Yes that seemed to be the problem.
> Although my IIS is set up to use Windows Authentication.
> I have set my web site up for <identity impersonation=True />
> Still didn't work.
That's correct.
> I have to explicitly add the userName and Password attributed to the
> identity element tag for it to work.
That's also correct.
> I was under the impression that impersonation should run as the user that
> the IIS session is running as. If I am using Windows Authentication this
> should be the user who is viewing the website, true?
That's not correct - the user who is viewing the website has nothing
whatsoever to do with the user under which ASP.NET is running...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net