Sunday, June 3, 2007

User Info w/o using Adsiedit

' On Error Resume Next
' Define variables
dim firstName
dim lastName
' Prompts to enter first name and loops till users does not enter a first name
Do while firstname=""
' msgbox("Please type your first name")
firstName=inputbox("Enter your first name:","First Name")
' If user presses cancel then move forward
If IsEmpty(firstname) Then
exit do
End If
Loop
' Prompts to enter last nameDo while lastname=""
' msgbox("Please type your last name")
lastName=inputbox("Enter your last name") ' If user presses cancel, then move forward
If IsEmpty(lastname) Then
exit do
End If
Loop
' Display AD properties only if a name has been entered
if firstname<>"" Or lastname<>"" then
Set objUser = GetObject("ldap://cn=&" "&lastname&",dc=abc,dc=com")
Set WMIUser = GetObject("winmgmts:{impersonationlevel=impersonate}!" &"/root/cimv2:Win32_UserAccount.Domain='ASIA'" & ",Name='" & objUser.sAMAccountName & "'")
WScript.Echo "Display Name: " & objUser.displayName
WScript.Echo "Office: " & objUser.physicalDeliveryOfficeName
WScript.Echo "Telephone Number: " & objUser.telephoneNumber
WScript.Echo "Home Phone: " & objUser.homephone
WScript.Echo "Login ID: " & objUser.sAMAccountName
WScript.Echo "Account Last Accessed on: " & objUser.whenChanged
WScript.Echo "Account Created on: " & objUser.whenCreated
WScript.Echo "User SID: " & WMIUser.SID
' Add more properties if needed

End If

2 comments:

Anju Shokeen said...

bahoot badiya ...par kya hai ye

Unknown said...

You have really made it easy... I wish I could meet you some day.. We have an opening in our company as Systems Engineer.. Would you be intrested.

You will get chance to work on AD, managing user accounts. Daily activities would also involve Symantec Alerts T/S and shell scripting.

We have our own sharepoint server... called eRoom. Good exposure bro