Advertisement

08.20.2008 at 08:42AM PDT, ID: 23663602 | Points: 500
[x]
Attachment Details

VB Script - AD property if a user is disabled/locked

Asked by jamiepryer in VB Script

Tags:

Hi,
I have some VB code, which will link into AD and tell me some information on a selected list of accounts, including:
- if they are "found" or "not found" in AD
- Users Full name, for that account
- user description
- user displayname (ie joe blogs)

i would also like to add into this script if the user is disabled and if the user is locked out.
Im not sure what the AD fields for this are tho?
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
For Each rCell In rWhole
    rCell.Select
    If rCell.Value = "" Then
        Exit For
    End If
        
    a = rCell.Address
    strName = rCell
 
    objCommand.CommandText = _
        "SELECT Name, description, displayname FROM 'LDAP://" & strDomain & "' WHERE objectCategory='user' " & _
            "AND Name='" & strName & "'"
    Set objRecordset = objCommand.Execute
 
    If objRecordset.RecordCount = 1 Then
        ActiveSheet.Range(a).Offset(0, 1) = "Found"
            ActiveSheet.Range(a).Offset(0, 2).Value = objRecordset.Fields("Name").Value
            ActiveSheet.Range(a).Offset(0, 4).Value = objRecordset.Fields("description").Value
            ActiveSheet.Range(a).Offset(0, 3).Value = objRecordset.Fields("displayname").Value
        'With ActiveSheet.Range(A).Offset(0, 1).Font
        With ActiveSheet.Range(a).EntireRow.Font
            .Bold = True
        End With
        With ActiveSheet.Range(a).Font
            .Bold = True
        End With
    Else
        ActiveSheet.Range(a).Offset(0, 1) = "Not found"
    End If
    
    i = i + 1
    objRecordset.Close
'Loop
Next
[+][-]08.20.2008 at 11:21AM PDT, ID: 22272436

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.27.2008 at 08:56AM PDT, ID: 22326272

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.26.2008 at 11:04AM PDT, ID: 22582064

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628