473,805 Members | 1,905 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Does anyone know how to tell if a local user account on a member server is
disabled using the directoryservic es 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 1853
Hi Brent,
Does anyone know how to tell if a local user account on a member server is
disabled using the directoryservic es 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 "IsAccountDisab led". 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(stri ng 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.Schema ClassName.ToLow er() == "user")
{
IADsUser intfUser = (deObj.NativeOb ject as IADsUser);
if(intfUser != null)
{
bResult = intfUser.Accoun tDisabled;
}
}

return bResult;
}

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

bool bIsDisabled = IsDisabled("Win NT://<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
5228
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 and find properties for these things but have not had any luck so far. Also i did a search on the Platform SDK doc's. It has examples in VB and C++ but these are not using DotNet and dont give any hint to a property that may be used. They seem...
10
9895
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
25112
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 you could help me. Here's the code: -------------------------- System.DirectoryServices.DirectorySearcher DSESearcher = new System.DirectoryServices.DirectorySearcher();
1
2545
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 WinNT provider. Any help would be appreciated. Thanks, Brent Grooms
3
13181
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 local Administrator (so they should have sufficient permissions). Would any one out there know how to programmatically add a local user to a local group in C#? TIA
0
856
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 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...
0
1438
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 successfully add domain users if I run the application under the identity of a domain account with administrative privileges on the local machine (or use windows auth with impersonation), but if I try to run it under a local account rather than a domain...
2
5394
by: Lidia | last post by:
Anybody has any ideas?
0
1610
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 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...
0
10609
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10360
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10366
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9185
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7646
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5542
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5677
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3845
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3007
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.