473,480 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1828
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
5197
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
9832
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
25046
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
2512
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
13149
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
842
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
1422
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
5365
by: Lidia | last post by:
Anybody has any ideas?
0
1584
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
6904
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
7032
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,...
0
7076
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...
1
6730
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...
0
6873
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...
1
4767
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
174
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...

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.