MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.
Option Explicit 'On Error Resume Next Dim objConnection, objCommand, objRecordSet Dim FindUser, strUser, strDN, arrPath, intLength, intNameLength Const ADS_SCOPE_SUBTREE = 2 Const intForReading = 1 Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection FindUser = InputBox("Please Enter A UserName", "Find User OU") If FindUser = "" Then MsgBox("No UserName Was Added") WScript.Quit Else strUser = FindUser End If objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.CommandText = _ "SELECT distinguishedName FROM 'LDAP://dc=domain.com,dc=com'WHERE objectCategory='user'AND sAMAccountName='" & strUser & "'" Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordSet.EOF strDN = objRecordSet.Fields("distinguishedName").Value arrPath = Split(strDN, ",") intLength = Len(arrPath(1)) intNameLength = intLength - 3 Wscript.Echo "User :" & strUser & Right(arrPath(1), intNameLength) objRecordSet.MoveNext Loop
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|Using VBScript. How to obtain the recomended paging file size?||8||109|
|I need an Excel Macro to filter the word "Project" in column H and expand the selection, then copy the results (all columns) to another sheet.||10||53|
|I'm trying to understand this simple vb code!||2||46|
|batch file or script||4||66|
Join the community of 500,000 technology professionals and ask your questions.