|
-
Jul 26th, 2005, 03:05 PM
#1
Thread Starter
New Member
search ad for attributes using username question
I'm a bit of a vb novice but this is what I am trying to do.
1. Get the currently logged on user
2. Querry AD for the sAMAccountName that = the username
3. Get the distinguished name of the user
4. Get the properties of both mailnickname and altrecipient
I don't want to have to specify a specific domain or OU initially. I think these can/should be variables. I don't want to have to have multiple scripts for different OUs.
The other problem I am having in what I have now is if the username is not the same as "cn=" in displayname then the script won't run.
any help is appriciated. This is what I have now.
*************************************************
on error resume next
set objshell = wscript.createobject("wscript.shell")
set objnetwork = wscript.createobject("wscript.network")
curuser = objnetwork.username
strUser = ("LDAP://CN=" & curuser & ",OU=X,OU=X,DC=X,DC=X,DC=X")
Set objItem = GetObject(strUser)
isswitch = 0
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
strname1 = objItem.Get("altrecipient")
strname2 = objItem.Get("mailNickname")
if lcase(left(strname1,8)) = "cn=quest" then
isswitch = 1
elseif left(strname2,1) = "" then
isswitch = 1
end if
if isswitch = 1 then wscript.quit
OpenMsg = objshell.popup ("Do not open Outlook! Your Outlook profile is currently being updated." & _
" If your Outlook or Blackberry Desktop software is currently running," & _
" click OK to close them or they will be automatically closed in 45 seconds." & _
" Profile Updating will begin when this window is closed.", 45, "Outlook Profile Update", 64)
set objService = getobject("winmgmts:")
for each Process in objService.InstancesOf("Win32_process")
if lcase(Process.Name) = "outlook.exe" then process.terminate()
if lcase(Process.Name) = "desktopmgr.exe" then process.terminate()
Next
EMWcall = chr(34) & "\\server\share$\update.bat" & chr(34)
exresult = objshell.run (emwcall, 0, true)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|