Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

vbscript that queries ldap from non-joined domain pc

$
0
0

Hello,

I trying to script out outlook 2010 signatures for my users.  I'm able to accomplish this if the user is logged into a pc that is in the domain.  However, most of the users do not log into the domain.  They log into the workstation only.  Essentially, I would like for the script to prompt for their domain username "ie: john.doe" and then the script queires against that and creates the signature files.  I can get the script to prompt for a username but nothing more.  I don't know how to connect back to the domain when the script is being run from a non-joined domain pc and I don;t know how to get what the user inputed as the username to bring back AD fields.  Here is what I have so far.  Any help is greatly appreciated.

On Error Resume Next
Const WdLineBreak = 6
Dim intLen
Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
strName = objUser.FirstName & " " & objUser.LastName
strTitle = objUser.Title
strDepartment = objUser.department
strAddress = objUser.streetAddress
strCity = objUser.physicalDeliveryOfficeName
strState = objUser.st
strZip = objUser.postalCode
strCompany = objUser.Company
strDirect = objUser.homePhone
strFax = objUser.faxNumber
strEmail = objUser.mail
strPhone = objuser.telephoneNumber
strMobile = objuser.mobile

= Len(strFax) + Len(strWWW)

Set objWord = CreateObject("Word.Application")

Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries

objSelection.ParagraphFormat.SpaceAfter = 0

objSelection.Font.Size = "13.5"
objSelection.Font.Name = "Franklin Gothic Medium"
objSelection.TypeText strName
objSelection.Font.Size = "10"
objSelection.InsertBreak WdLineBreak
objSelection.TypeText strTitle
objSelection.InsertBreak WdLineBreak
objSelection.Font.Size = "10"
objSelection.TypeText strDepartment
objSelection.Font.Size = "9"
objSelection.InsertBreak WdLineBreak
objSelection.TypeText "City of New York"
objSelection.InsertBreak WdLineBreak
objSelection.TypeText "P.O. Box 55555"
objSelection.InsertBreak WdLineBreak
objSelection.TypeText strAddress & "("&strZip&")"
objSelection.InsertBreak WdLineBreak
objSelection.TypeText "New York, NY 55555-5555"
objSelection.InsertBreak WdLineBreak
objSelection.TypeText "o: " & strPhone
objSelection.InsertBreak WdLineBreak
objSelection.TypeText strMobile
objSelection.InsertBreak WdLineBreak
objSelection.TypeText strFax
objSelection.InsertBreak WdLineBreak
objSelection.InsertBreak WdLineBreak
objSelection.TypeText strEmail
objSelection.InsertBreak WdLineBreak
objSelection.Hyperlinks.Add objSelection.Range, " " & strWWW & " ", , , strWWW, "_blank"

Set objSelection = objDoc.Range(objSelection.End-intLen,objSelection.End)
objSelection.Font.Name = "Franklin Gothic Medium"
objSelection.Font.Size = "9"
Set objSelection = objDoc.Range()

objSignatureEntries.Add "AD New Message", objSelection
objSignatureObject.NewMessageSignature = "AD New Message"
objDoc.Saved = True
objWord.Quit

On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
strName = objUser.FirstName & " " & objUser.LastName
strTitle = objUser.Title
strCompany = objUser.Company
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
objSelection.Font.Size = "13.5"
objSelection.Font.Name = "Franklin Gothic Medium"
objSelection.TypeText strName
objSelection.Font.Size = "10"
objSelection.InsertBreak WdLineBreak
objSelection.TypeText strTitle
objSelection.InsertBreak WdLineBreak
objSelection.Font.Size = "10"
objSelection.TypeText strDepartment
objSelection.Font.Size = "9"
objSelection.InsertBreak WdLineBreak
objSelection.TypeText "City of New York"
objSelection.InsertBreak WdLineBreak
objSelection.TypeText "P.O. Box 55555"
objSelection.InsertBreak WdLineBreak
objSelection.TypeText strAddress & "("&strZip&")"
objSelection.InsertBreak WdLineBreak
objSelection.TypeText "New York, NY 55555-5555"
objSelection.InsertBreak WdLineBreak
objSelection.TypeText "o: " & strPhone
objSelection.InsertBreak WdLineBreak
objSelection.TypeText strMobile
objSelection.InsertBreak WdLineBreak
objSelection.TypeText strFax
objSelection.InsertBreak WdLineBreak
objSelection.InsertBreak WdLineBreak
objSelection.TypeText strEmail
objSelection.InsertBreak WdLineBreak
objSelection.Hyperlinks.Add objSelection.Range, " " & strWWW & " ", , , strWWW, "_blank"
Set objSelection = objDoc.Range()
objSignatureEntries.Add "AD Reply", objSelection
objSignatureObject.ReplyMessageSignature = "AD Reply"
objDoc.Saved = True
objWord.Quit


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>