Archive for September, 2009

I had to come up with a way to vaildate some domain user credentials for a support package. Here’s the code in it’s simplest vbs form :

‘“““““““““““““““““““““““““““““

Dim objDSO, objDomain, objSysInfo, strDomain

Set objSysInfo = CreateObject(”ADSystemInfo”)
strDomain = objSysInfo.DomainShortName

Set objDSO = GetObject(”WinNT:”)
On Error Resume Next
Set objDomain = objDSO.OpenDSObject(”WinNT://” & strDomain, “username”, “password”, ADS_SECURE_AUTHENTICATION)

If Err.Number <> 0 Then
   
    Select Case Err.Number
      Case -2147023570
        MsgBox “Unknown user name or password.”, 64, “Windows Authentication”
      Case -2147022987
        MsgBox “User account is locked.”, 64, “Windows Authentication”
      Case -2147023565
        MsgBox “User account is disabled.”, 64, “Windows Authentication”
      Case Else
         MsgBox “Unknown error, unable to verify credentials.” & vbCRLF & _
         “Error Code: ” & Err.Number, 64, “Windows Authentication”
    End Select
   
    Set objDSO = Nothing
    Set objDomain = Nothing
    Set objSysInfo = Nothing
   
    Wscript.Quit
   
End If

Set objDSO = Nothing
Set objDomain = Nothing
Set objSysInfo = Nothing

MsgBox “Credentials verified.”, 64, “Windows Authentication”

Use the FormBorderStyle Property to prevent form resizing - VB Express 2008.

FormBorderStyle.FixedSingle will prevent users from manually resizing the form. To prevent the form from being resized through code, handle the SizeChanged event and set the size back to the fixed size you want it to be.

Had to play around with this the other day on a new install, so here’s how :

Fom the Tools Menu, select Options -> Text Editor -> Basic -> General.
Click the “Line Numbers” checkbox.