Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query WinNT provider for user account info

Status
Not open for further replies.

tumblor

Technical User
Nov 14, 2001
7
US
I work in an NT environment and I am putting together scripts that get around opening up user mangler and waiting for it to enumerate 1000's of names.

I manage a lot of security groups, and I want to do the following. People often ask me to add and delete users from groups, so what I have is the users' first and last names. I want to bind to the domain and find out the users' username from this information.

I've come across a script that binds to an LDAP provider, but not one that works within an NT world.
 
Do you have a naming convention? Shouldn't you be able to determine the login name based on the information you already have?

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
We do have a naming convention, but there the SAM for the security domain is massive! Middle initials are common, and names don't always match the convention to a tee.

I saw a script that allow you to query an LDAP provider through VBScript, is there a way to do it with an NT domain?
 
If you can get the Windows Management Instrumentation Core ( onto the NT box in question, then it is pretty easy. The following is VB code, but it ought to be relatively easy to port the important bits to VBScript. Althugh this example only retrieves the .Name property of the user account, the info on this URL shows the other properties that you can both search against in the query or retrieve in the results ()

Code:
[COLOR=blue]
Private Sub Command1_Click()
    Dim strComputer As String
    Dim objWMIService As Object
    Dim colItems As Object
    Dim objItem As Object
    Dim strName As String
    
    strName = "Jones" ' example name to look for
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery("Select * from Win32_UserAccount where Fullname like '%" & strName & "%'", , 48)
    For Each objItem In colItems
        List1.AddItem objItem.Name
    Next
End Sub
[/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top