473,385 Members | 1,351 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,385 software developers and data experts.

how to tell if local account is disabled with directoryservices.dll and vb.net

Does anyone know how to tell if a local user account on a member server is
disabled using the directoryservices dll and vb.net? I know since it is not
an LDAP server that i will have to use the WinNT provider. Any help would
be appreciated.

Thanks,

Brent Grooms
Jul 21 '05 #1
1 1823
Hi Brent,
Does anyone know how to tell if a local user account on a member server is
disabled using the directoryservices dll and vb.net?


No problem - you just need to a) bind to the user using the WinNT
provider, and b) get the native ADSI "IADsUser" interface - that's the
easiest, since it has an attribute called "IsAccountDisabled". For
that to work, you'll also need to add another reference to your
project, to the COM "ActiveDs Type Library", and add a "using
ActiveDs; " line to the beginning of your source file.

Sample in C# - should be easy enough to translate to VB.NET:

private bool IsDisabled(string aUserPath)
{
bool bResult = false;
DirectoryEntry deObj = new DirectoryEntry(aUserPath);

// make sure it's a user - otherwise, we don't have
// the concept of "disabled", hence return false always
if(deObj.SchemaClassName.ToLower() == "user")
{
IADsUser intfUser = (deObj.NativeObject as IADsUser);
if(intfUser != null)
{
bResult = intfUser.AccountDisabled;
}
}

return bResult;
}

Now if you call this method like this, you should be getting back your
results:

bool bIsDisabled = IsDisabled("WinNT://<machine>/<username>,User");

e.g.

if(IsDisabled("WinNT://MyPC/Guest,User")
{
.........
}
HTH
MArc
Jul 21 '05 #2

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

Similar topics

14
by: Arran Pearce | last post by:
Hi, I am looking for a way to use System.DirectoryServices to find all users on a domain whos accounts are either locked out or disabled. I have used ADSIEdit and the mmc schema add-in to try...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
1
by: Angelo | last post by:
Hi, I've been trying to create a user in Active Directory. So far this works, however default the user is disabled. I've been trying so much code to enable the user, but without success, perhaps...
1
by: Brent Grooms | last post by:
Does anyone know how to tell if a local user account on a member server is disabled using the directoryservices dll and vb.net? I know since it is not an LDAP server that i will have to use the...
3
by: enilno | last post by:
I'm working on a C# app., and I need to programmatically add a local user to a local group on the computer on which the app. is running. When end-users run this app., they will be logged on as...
0
by: John Wright | last post by:
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...
0
by: Chad Dressler | last post by:
I'm trying to use System.DirectoryServices to add a domain user to a local group via a web application which runs under the identity of a local admin account. Is this possible? I can...
2
by: Lidia | last post by:
Anybody has any ideas?
0
by: Big Charles | last post by:
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.