This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / 如何写个VB程序看Windows domain ID是否被lock住了?
-jihu06(maskofzZzorro);
2007-2-28
{599}
(#3524907@0)
-
ADSI (Active Directory Service Interface) is a good choice, although most of cases are through VBScript. http://www.microsoft.com/technet/scriptcenter/guide/sas_vbs_dcot.mspx?mfr=true
-pnpn(双飞雁);
2007-2-28
(#3526391@0)
-
Thanks but I don't think I can have any access to AD or any other servers. All what I can do is from client side.I am thinking of simply using the command "runas" to check if the account has been locked from my workstation.
What's the VB object to run this "runas" command? Thanks.
-jihu06(maskofzZzorro);
2007-3-1
{176}
(#3527160@0)
-
you can use the sampe inside with little change. what you only need to do is to find out which bit in "userAccountControl" is locking flag.Const ADS_UF_ACCOUNTDISABLE = 2
Set objUser = GetObject _
("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
intUAC = objUser.Get("userAccountControl")
If intUAC AND ADS_UF_ACCOUNTDISABLE Then
Wscript.Echo "The account is disabled"
Else
Wscript.Echo "The account is enabled"
End If
-yr2much(伟大的豪哥的哥);
2007-3-1
{314}
(#3527241@0)
-
I have no experience with LDAP. Question: will security allow me to inquire LDAP server like this? I mean if this small .vbs is running on my machine?
-jihu06(maskofzZzorro);
2007-3-1
(#3527604@0)
-
if you don't have permission, you can't do anything about it regardless what tool you use
-yr2much(伟大的豪哥的哥);
2007-3-1
(#3527610@0)
-
See, I am thinking a different way.Look at this "runas" DOS command. All I want to do is write a .bat or .vbs to run this "runas" command and get back the response. I just don't know how to write such a script.
C:\Documents and Settings\jihu>runas /user:BNS\JIHu notepad
Enter the password for BNS\JIHu:
Attempting to start notepad as user "BNS\JIHu" ...
RUNAS ERROR: Unable to run - notepad
1326: Logon failure: unknown user name or bad password.
C:\Documents and Settings\jihu>
-jihu06(maskofzZzorro);
2007-3-1
{468}
(#3527645@0)
-
runas is not different than other executables, you just have to either hard-code password in script (not a good idea) or type in while it runs.
-yr2much(伟大的豪哥的哥);
2007-3-1
(#3527767@0)
-
Thank you very much for all your help. But I just found out that "runas" is not scriptable.
-jihu06(maskofzZzorro);
2007-3-1
{163}
(#3528261@0)
-
I didn't try it myself, but you should be able to do "runas" within vbscript by embeding it into anohter shell host. "runas /user:SAS\SAFSBILLING c:\windows\system32\cscript.exe c:\full_path\add_domainuser2localadmin.vbs"google runas vbscript, there are plenty examples.
-yr2much(伟大的豪哥的哥);
2007-3-1
{49}
(#3528339@0)
-
Hey, I found a better command,
-jihu06(maskofzZzorro);
2007-3-2
{602}
(#3530234@0)
-
This /OUTPUT writes to the Windows CLIPBOARD, now I just need to find out how to get it from CLIPBOARD in VBS.C:\Documents and Settings\Owner>WMIC /OUTPUT:CLIPBOARD USERACCOUNT WHERE "Name='Owner'" get Lockout
-jihu06(maskofzZzorro);
2007-3-2
{105}
(#3530251@0)
-
Then found this from this URL, it works well.
-jihu06(maskofzZzorro);
2007-3-2
{194}
(#3530262@0)
-
Now my job can be nicely done, and they are paying me thousands of dollars on this. Haha.
-jihu06(maskofzZzorro);
2007-3-2
(#3530267@0)
-
Shit, WMIC is not avaiable in Window2000. Have to use something else.
-jihu06(maskofzZzorro);
2007-3-5
(#3534250@0)