DirectoryEntry without using admin user: how to check if account's expired



Hello,
Programming in VS2003-ASP.NET 1.1, I have this problem: Using
DirectoryEntry and without any admin user, how can I check if a domain
account, that try to login, has expired?
Scenario: User load web application and login using account and
password of the Active Directory.
But user account of ActiveDirectory has expired (or password could be
expired). For security reason, we don't want to use any account with
admin privilegies for connecting through AD. So if user account "jdoe"
with password:"jdoe_password" try to login, how to determine if
account has expired.
Code:

Dim Domain As String = "DOMAINXXX"
Dim sUserName="jdoe": Dim sPassword="jdoe_password"
Dim myEntry As System.DirectoryServices.DirectoryEntry =
New System.DirectoryServices.DirectoryEntry("LDAP://"; & Domain,
sUserName, sPassword,
System.DirectoryServices.AuthenticationTypes.Secure)
myEntry.Username = sUserName
myEntry.Password = sPassword

Dim mySearcher As
System.DirectoryServices.DirectorySearcher = New
System.DirectoryServices.DirectorySearcher(myEntry)
Dim myResult As System.DirectoryServices.SearchResult

mySearcher.Filter = "(&(objectCategory=person)
(objectClass=user)(userPrincipalName=" & UserName & "*))"

Dim x as String = myResult.Properties("sAMAccountName")(0) ''<-- it
gets 'jdoe'
Dim y as String = myResult.Properties("userAccountControl")(0) ''<--
it gets Nothing

I don't think it's impossible, or that you have to use an admin user
to get that (if you have to use an admin user for connecting to AD,
what about security?)
Thanks
.



Relevant Pages

  • Re: Lock Out a User in Win XP home?
    ... > lock feature of XP is generally useless. ... I do not want to delete the account and probably lose all it's ... > restricted users that can be managed by an admin user ... ...
    (microsoft.public.windowsxp.security_admin)
  • Re: User admin disapears
    ... It is probably disappearing because another account has ... At a login prompt, with no users switched out, try pressing ... alt-cntrl-del twice and then manually logging in with the ... > rid of the new softare did not retreave my admin user. ...
    (microsoft.public.windowsxp.security_admin)
  • Re: Software Update no longer runs or lists installed updates :-(
    ... I have to say the display of the installed packages to non-admin users ... What Apple needs is a 'ro admin' account. ... that's why I don't login as the admin user. ...
    (comp.sys.mac.system)
  • Re: OS X Leopard and Office 2004 Student Ed
    ... Your old and new user IDs show that you are running as an Admin user ... (501 is the first UID assigned at install time, ... In your shoes, I'd migrate my everyday use to the new 502 account, ...
    (microsoft.public.mac.office)
  • Re: Need last logon time and account creation.
    ... Time account was created. ... and I find that the variable DomainName is assigned here: ... ' * Flag error Code ... Dim DomainName, DomainName2, strDN, concat, obj ...
    (microsoft.public.scripting.vbscript)