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