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