473,545 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 IsAccountDisabl ed(ByVal strDomain As String, ByVal
strAccount As String) As Boolean
Dim objUser
objUser = GetObject("WinN T://" & strDomain & "/" & strAccount & ",user")
IsAccountDisabl ed = objUser.Account Disabled
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.Director yServices namespace but I am
having problems finding code to do this. Any help is much appreciated.

John

CODE:
Public Function ValidateActiveD irectoryLogin(B yVal 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,
AuthenticationT ypes.Secure)

Dim Searcher As New DirectorySearch er(Entry)

Searcher.Search Scope = SearchScope.One Level

Try

Dim Results As SearchResult = Searcher.FindOn e

Success = Not (Results Is Nothing)

Catch ex As Exception

Success = False

End Try

Return Success

End Function
Aug 25 '06 #1
0 846

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

Similar topics

4
3693
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. This must work for either a domain or a local machine account. I have tried to find examples from the web and it seems every example that I have found...
0
1371
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
1905
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
4193
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - I have window.status="Moomin"; why doesn't the statusbar change? ----------------------------------------------------------------------- When changing the status in an event (e.g. onmouseover) you should return true from the event. Also a number of browsers...
3
2271
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
9815
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 message: "An access denied error was returned while attempting to change a service." It appeared to do what I asked it to do but every time I click...
1
1935
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 other domains. How do i do this? Example: User comes to my hosting account via www.siteA.com. The whole time the user is on the site the base URL...
2
2021
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 from the site below : http://en.csharp-online.net/User_Management_with_Active_Directory%E2%80%94Determining_Domain-Wide_Account_Policies But i get...
0
7499
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7689
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7943
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7456
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6022
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.