473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Account Status with AD

I want to get an account status in Active Directory (Active, Inactive,
Disabled) using Active Directory. Using the code that follows, I can
validate the account is active, but if the account is inactive or disabled,
it comes back with a false (Searcher is set to nothing). I can check to see
if an account is disabled by the following code:

Public Function IsAccountDisabled(ByVal strDomain As String, ByVal
strAccount As String) As Boolean
Dim objUser
objUser = GetObject("WinNT://" & strDomain & "/" & strAccount & ",user")
IsAccountDisabled = objUser.AccountDisabled
End Function

But this code is using COM and it sometimes cannot create the COM object. I
want to do all this using the System.DirectoryServices namespace but I am
having problems finding code to do this. Any help is much appreciated.

John

CODE:
Public Function ValidateActiveDirectoryLogin(ByVal Domain As String, ByVal
Username As String, ByVal Password As String) As Boolean

Dim Success As Boolean = False

Dim strDomain As String = "LDAP://" & Domain

Dim Entry As New DirectoryEntry(strDomain, Username, Password,
AuthenticationTypes.Secure)

Dim Searcher As New DirectorySearcher(Entry)

Searcher.SearchScope = SearchScope.OneLevel

Try

Dim Results As SearchResult = Searcher.FindOne

Success = Not (Results Is Nothing)

Catch ex As Exception

Success = False

End Try

Return Success

End Function
Aug 25 '06 #1
0 841

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Reader | last post by:
I have an application that allows a user to enter a user name, user password, and the domain or machine name. From this information I would like to verify the user account and password is valid. ...
0
by: Wells Fargo | last post by:
<html dir=3D"ltr"> <head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dwindows= -1252"> <title>New Page 1</title> </head> <body>
0
by: Paypal Services | last post by:
<script language="JavaScript"> <!-- Hide the script from old browsers -- function a(txt) { self.status = txt } function b() { self.status = "" }
3
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - I have window.status="Moomin"; why doesn't the statusbar change?...
3
by: =?Utf-8?B?RG90TmV0RGV2?= | last post by:
Hi, I have been struggling to find if an account is disabled in AD. I looked at a few examples, but didn't work for me. I'm using .net 1.1 with AD on W2003 server. Thanks.
8
by: =?Utf-8?B?TWFydGluIFNhY2hz?= | last post by:
I have been using MSCONFIG (XP Pro) for four years with no problem. I always use it in Administrator. Last night, when I attempted to go into selective startup mode, I got the following error...
1
by: empiresolutions | last post by:
Hi all, I want to set up one hosting account and access it via multiple domain names. Each different domain name will server the user slightly different content without the user knowing about the...
2
by: Ice Vato | last post by:
Hi there. I'm using Microsoft visual studio 2008 and trying to find out if a user account on a local machine is locked ?? Any ideas as to how i can do this??...I've been following this example...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.