SPSFAQ
SharePoint Server Frequently Asked Questions
affiliate links


Buy a sponsored link

You could have a link to your website on every page of SPSFAQ.


Customising SharePoint

SPSFAQ0301108 - How can I access the metadata of a checked in document with vbscript? - 0 Comments - stephencummins - Fri, Apr 18th, 2003 - Customisation
The most recent Metadata that is contained in the doc profile as a result of checking in a doc and not publishing the doc can only be obtained by opening the doc.

Here's a function that builds an XML doc from all of the fields in a doc profile. Don't let the size of it overwhelm you, there's a lot of repetative stuff...

function GetDocumentData(strDocURL)

' Open connection
dim oConn
set oConn = server.CreateObject("ADODB.Connection")
oConn.Provider = "ExOLEDB.DataSource"
oConn.Open Application( "ERS_DEFAULT_DOC_FOLDER" )

strOut = "<ers xmlns='urn:schemas-mycompany-com:ers-documents:contribution:' xmlns:base='urn:schemas-mycompany-com:exodus:basic-attributes:' xmlns:user='urn:schemas-mycompany-com:exodus:users:' xmlns:key='urn:schemas-mycompany-com:exodus:keywords:' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:dt='urn:schemas-microsoft-com:datatypes'>"

' Get the document
set oCDODoc = Server.CreateObject("CDO.KnowledgeDocument")

' Get the document's most recent version
oCDODoc.DataSource.open strDocURL, oConn, adModeRead
strDocURLVersioned = oCDODoc.fields("urn:schemas-microsoft-com:publishing:LastUnapprovedVersion") & ""
if strDocURLVersioned = "" then
strDocURLVersioned = oCDODoc.fields("DAV:href")
end if


' Rebind to current version
oCDODoc.DataSource.open strDocURLVersioned,oConn,adModeRead

' Retrieve profile fields
strOut = strOut & "<base:title>" & StripSpecialCharacters(oCDODoc.Title) &"</base:title>"
strOut = strOut & "<summary></summary>"
strOut = strOut & "<base:description>" & StripSpecialCharacters(oCDODoc.Description) & "</base:description>"
strOut = strOut & "<base:author>" & StripSpecialCharacters(oCDODoc.Author) & "</base:author>"
strOut = strOut & "<base:contributedby>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Contributed By")) & "</base:contributedby>"
strOut = strOut & "<base:industries>"
oCDOFieldArray = oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Industry")
if isarray(oCDOFieldArray) then
for each oCDOItem in oCDOFieldArray
strOut = strOut & "<base:industry>"
strOut = strOut & "<key:display-name>" & StripSpecialCharacters(oCDOItem) & "</key:display-name>"
strOut = strOut & "</base:industry>"
next
else
strOut = strOut & "<base:industry></base:industry>"
end if
strOut = strOut & "</base:industries>"
strOut = strOut & "<base:country>"
strOut = strOut & "<key:display-name>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Country")) & "</key:display-name>"
strOut = strOut & "</base:country>"
strOut = strOut & "<base:contenttype>"
strOut = strOut & "<key:display-name>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Content Type")) & "</key:display-name>"
strOut = strOut & "</base:contenttype>"
strOut = strOut & "<base:function>"
strOut = strOut & "<key:display-name>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Function")) & "</key:display-name>"
strOut = strOut & "</base:function>"
strOut = strOut & "<base:office>"
strOut = strOut & "<key:display-name>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Office")) & "</key:display-name>"
strOut = strOut & "</base:office>"
strOut = strOut & "<base:segments>"
oCDOFieldArray = oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Segment")
if isarray(oCDOFieldArray) then
for each oCDOItem in oCDOFieldArray
strOut = strOut & "<base:segment>"
strOut = strOut & "<key:display-name>" & StripSpecialCharacters(oCDOItem) & "</key:display-name>"
strOut = strOut & "</base:segment>"
next
else
strOut = strOut & "<base:segment></base:segment>"
end if
strOut = strOut & "</base:segments>"
strOut = strOut & "<base:servicelines>"
oCDOFieldArray = oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Service Line")
if isarray(oCDOFieldArray) then
for each oCDOItem in oCDOFieldArray
strOut = strOut & "<base:serviceline>"
strOut = strOut & "<key:display-name>" & StripSpecialCharacters(oCDOItem) & "</key:display-name>"
strOut = strOut & "</base:serviceline>"
next
else
strOut = strOut & "<base:serviceline></base:serviceline>"
end if
strOut = strOut & "</base:servicelines>"

strOut = strOut & "<base:serviceofferings>"
oCDOFieldArray = oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Service Offering")
if isarray(oCDOFieldArray) then
for each oCDOItem in oCDOFieldArray
strOut = strOut & "<base:serviceoffering>"
strOut = strOut & "<key:display-name>" & StripSpecialCharacters(oCDOItem) & "</key:display-name>"
strOut = strOut & "</base:serviceoffering>"
next
else
strOut = strOut & "<base:serviceoffering></base:serviceoffering>"
end if
strOut = strOut & "</base:serviceofferings>"
strOut = strOut & "<base:specializations>"
oCDOFieldArray = oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Specialization")
if isarray(oCDOFieldArray) then
for each oCDOItem in oCDOFieldArray
strOut = strOut & "<base:specialization>"
strOut = strOut & "<key:display-name>" & StripSpecialCharacters(oCDOItem) & "</key:display-name>"
strOut = strOut & "</base:specialization>"
next
else
strOut = strOut & "<base:specialization></base:specialization>"
end if
strOut = strOut & "</base:specializations>"
strOut = strOut & "<base:team>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Team")) & "</base:team>"
strOut = strOut & "<base:fees>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Fees")) & "</base:fees>"
strOut = strOut & "<base:clientname>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Client Name")) & "</base:clientname>"
strOut = strOut & "<base:primarycontact>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Primary Contact")) & "</base:primarycontact>"
strOut = strOut & "<base:competitor>"
strOut = strOut & "<key:display-name>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Competitors")) & "</key:display-name>"
strOut = strOut & "</base:competitor>"
strOut = strOut & "<base:attachmenturl>" & oCDODoc.Fields("DAV:href") & "</base:attachmenturl>"
strOut = strOut & "<base:attachmentname>" & oCDODoc.Fields("DAV:displayname") & "</base:attachmentname>"
strOut = strOut & "<base:attachmentlanguage>"
strOut = strOut & "<key:display-name>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Language")) & "</key:display-name>"
strOut = strOut & "</base:attachmentlanguage>"

strOut = strOut & "<base:engagementmanager>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Engagement Manager")) & "</base:engagementmanager>"
strOut = strOut & "<base:smename>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#SME Name")) & "</base:smename>"
strOut = strOut & "<base:smecomments>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Subject Matter Expert Comments")) & "</base:smecomments>"
strOut = strOut & "<base:cmcomments>" & StripSpecialCharacters(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Content Manager Comments")) & "</base:cmcomments>"
strOut = strOut & "<base:documentstatus>" & oCDODoc.Fields("urn:schemas-microsoft-com:office:office#Doc Status") & "</base:documentstatus>"
strOut = strOut & "<base:publicationdate>" & oCDODoc.Fields("urn:schemas-microsoft-com:office:office#PublishedDate") & "</base:publicationdate>"
strOut = strOut & "<base:expirationdate>" & oCDODoc.Fields("urn:schemas-microsoft-com:office:office#ExpiresDate") & "</base:expirationdate>"
if isdate(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#SubmittedDate")) then
strOut = strOut & "<base:submissiondate>" & formatdatetime(oCDODoc.Fields("urn:schemas-microsoft-com:office:office#SubmittedDate"),vbshortdate) & "</base:submissiondate>"
else
strOut = strOut & "<base:submissiondate></base:submissiondate>"
end if
strOut = strOut & "</ers>"
set oCDODoc = Nothing
GetDocumentData = strOut
end function

Ted Gamble
SPSFAQ0301107 - Is there code to manipulate the multi-value for categories? Brian Dickinson - 0 Comments - stephencummins - Fri, Apr 18th, 2003 - Customisation
I currently have a large directory structure which matches up 1:1 with our category structure. I would like to create seperate document profiles at the top of each major directory to make life easier for my users when publishing documents.

What I need is code or a way to manipulate the multi-value for categories. I opened a case with Microsoft and they wanted to write something for our particular case. I was wondering if anyone has already went down this path...it seems like it would be a common occurance.

Brian Dickinson

Here's your solution: The code can be placed in a VBScript file (.vbs) and then run on a sps server either from the command line or from scheduled tasks.

We have a nightly task that keeps our SPS category tree and it's documents in sync with an external application, whose data is housed in sql server. User's maintain "keyword" tables (which are what we base our categories on). So, for example, if a user changed the Auto keyword to Automobiles, my code has to do several things. First, it creates a new Automobile category. Next, it updates all documents where the category contains Auto and changes it to Automobiles. Finally, it deletes the old Auto category. The script runs nightly via scheduled tasks, under a coordinator service account.

oDoc.PromptToAuthenticate =False
oDoc.DataSource.open strDocURLVersioned, oSPSConnIn, adModeReadWrite

' Replace the field values
dim arValue1
dim arValue2

arValue1 = UpdateDocField(oDoc, strProfileFieldToUpdate, strOldValueIn, strNewValueIn)
arValue2 = UpdateDocCategory(oDoc, strProfileFieldToUpdate, strOldValueIn, strNewValueIn)

oDoc.Fields("urn:schemas-microsoft-com:office:office#" & strProfileFieldToUpdate) = arValue1
oDoc.Categories = arValue2

' Update and save the doc
oDoc.Fields.Update
oDoc.DataSource.Save
'--------------------------------------------------------------------------------
' Updates the document Profile field
'--------------------------------------------------------------------------------
Function UpdateDocField (oDocIn, strProfileFieldToUpdateIn, strOldValueIn, strNewValueIn)

dim arFieldValues
dim strFieldName
dim oFieldItem
dim i
' Update the Profile Field
strFieldName = "urn:schemas-microsoft-com:office:office#" & strProfileFieldToUpdateIn
arFieldValues = oDocIn.Fields(strFieldName)
if isarray(arFieldValues) then
for i = lbound(arFieldValues) to ubound(arFieldValues)
if trim(lcase(arFieldValues(i))) = trim(lcase(strOldValueIn)) then
arFieldValues(i) = strNewValueIn
Logit "Updating " & strProfileFieldToUpdateIn & " in " & oDocIn.displayname & " from " & strOldValueIn & " to " & strNewValueIn
strCompleteMessage = strCompleteMessage & "Updating " & strProfileFieldToUpdateIn & " in " & oDocIn.displayname & " from " & strOldValueIn & " to " & strNewValueIn & vbcrlf
end if
next
else
if trim(lcase(arFieldValues)) = trim(lcase(strOldValueIn)) then
arFieldValues = strNewValueIn
Logit "Updating " & strProfileFieldToUpdateIn & " in " & oDocIn.displayname & " from " & strOldValueIn & " to " & strNewValueIn
strCompleteMessage = strCompleteMessage & "Updating " & strProfileFieldToUpdateIn & " in " & oDocIn.displayname & " from " & strOldValueIn & " to " & strNewValueIn & vbcrlf
end if
end if
UpdateDocField = arFieldValues
End Function
'--------------------------------------------------------------------------------
' Updates the document Category field
'--------------------------------------------------------------------------------
Function UpdateDocCategory (oDocIn, strProfileFieldToUpdateIn, strOldValueIn, strNewValueIn)
dim arFieldValues
dim strFieldName
dim oFieldItem
dim i
' Update the Category Field
dim strOldCategoryValue
strOldCategoryValue = ":" & strProfileFieldToUpdateIn & ":" & strOldValueIn
dim strNewCategoryValue
strNewCategoryValue = ":" & strProfileFieldToUpdateIn & ":" & strNewValueIn
arFieldValues = oDocIn.Categories
if isarray(arFieldValues) then
for i = lbound(arFieldValues) to ubound(arFieldValues)
if trim(lcase(arFieldValues(i))) = trim(lcase(strOldCategoryValue)) then
arFieldValues(i) = strNewCategoryValue
Logit "Updating Categories in " & oDocIn.displayname & " from " & strOldCategoryValue & " to " & strNewCategoryValue
strCompleteMessage = strCompleteMessage & "Updating Categories in " & oDocIn.displayname & " from " & strOldCategoryValue & " to " & strNewCategoryValue & vbcrlf
end if
next
end if
UpdateDocCategory = arFieldValues
End Function

Ted Gamble
SPSFAQ0302106 - How do I perform a WebDAV query with .NET? - 0 Comments - stephencummins - Mon, Mar 24th, 2003 - Customisation
To perform webDAV request in .NET you need to use WebRequest and WebResponse.

Here is a small function that gets the workspace URL and the query SQL and returns the results in XML form.

Imports System.Text
Imports System.Net
Imports System.IO


Private Function executeQuery(ByVal Url As String, ByVal sQuery As String) As String
Dim oWriter As StreamWriter
Dim oRequest As HttpWebRequest
Dim sbRequest As New StringBuilder(1024)
Dim sRequest As String
Dim sResponse As String


'build the webDAV request
sbRequest.Append("<?xml version=""1.0"" encoding=""utf-8""?>")
sbRequest.Append("<a:searchrequest xmlns:a=""DAV:"">")
sbRequest.Append("<a:sql>")
sbRequest.Append(sQuery)
sbRequest.Append("</a:sql></a:searchrequest>")
sRequest = sbRequest.ToString()

'create HttpWebRequest object
oRequest = DirectCast(WebRequest.Create(Url), HttpWebRequest)

'set the request headers
oRequest.Method = "SEARCH"
oRequest.ContentType = "text/xml"
oRequest.AddRange("rows", 0, 19) ' get the first 20 results...
oRequest.Headers.Add("MS-Search-TotalHits", "t")
oRequest.Headers.Add("MS-Search-UseContentIndex", "t")
oRequest.Headers.Add("MS-SEARCH-MAXROWS", "200")
oRequest.ContentLength = New System.Text.UTF8Encoding().GetByteCount(sRequest)


Try
'set the Credentials to the current user
oRequest.Credentials = CredentialCache.DefaultCredentials()
'send the request
oWriter = New StreamWriter(oRequest.GetRequestStream())
oWriter.Write(sRequest)
Catch ex As Exception
MsgBox(ex.Message)
Finally
If Not oWriter Is Nothing Then
oWriter.Close()
End If
End Try

Dim oResponse As HttpWebResponse
Dim oReader As StreamReader

Try
'get the HttpWebResponse object
oResponse = DirectCast(oRequest.GetResponse(), HttpWebResponse)

'read the response
oReader = New StreamReader(oResponse.GetResponseStream())
sResponse = oReader.ReadToEnd()
Catch ex As Exception
MsgBox(ex.Message)
Finally
If Not oResponse Is Nothing Then
oResponse.Close()
End If
If Not oReader Is Nothing Then
oReader.Close()
End If
End Try
Return (sResponse)
End Function

Alon Carmeli, MOCH
SPSFAQ0301104 - Does anybody know of a way to generate a unique docid? Juby Vembenil - 0 Comments - stephencummins - Thu, Feb 20th, 2003 - Customisation
Here's an interesting tidbit of Sharepoint knowledge: Did you know that any property defined in the Base Document profile can be referenced by any other profile - even if you don't assign that property to the profile? For instance, if I add a property to the Base Doc profile called "OurDocID" but don't add it to the "All Docs" profile, I can still programmatically add a value to that field. Even better, your users will never be permitted to add or change the value!

Check it out - set up a test profile with one less value than the BaseDoc profile. Throw a bit of VB code together that will check in a document and set the field properties - there's a piece of the code at the end of this comment. Then, use something that will display the workspace data - like the kStore Explorer Beta (www.kcura.com). You will see the property and the value are there, but will not be displayed when a user tries to check in a new document.

"So what?", you ask. Knowing this, now you can decide on a course of action best suited to your programming abilities to take advantage of this “Hidden” property. You could add your own Event Sink (Uncle Bill says that’s a no-no, so be careful!) or you could modify the code that is called when a document is added to the store.

Just check to see if the property already has a value, if not, assign one based on some algorithm you want (like look it up in a database).

“Cool!”, you say, “but how do I display the values?” - Any one of a hundred ways, but here are two:

1. Write a program that queries the store and displays/reports on the information

2. Modify the existing “Matching Documents” web part to query for the value and display it by modifying the “SearchResultsPart.XSL” file to display the value.

Your choice will depend on your reasons for wanting to do this in the first place - are you linking this info to an external program? Then maybe you don't have to worry about displaying it inside of Sharepoint, you just reference through code in this other application.

The possibilities are endless - one of the many cool (and practical) benefits of Sharepoint!

Good luck - and don't forget to post back here when you decide on, and code, a solution!

Part of the VB code required to check in a document and set some properties:

Sub CheckInFiles(FullName As String, strPath As String, RawName As String, Profile As String, f_sHref As String)
Dim myFields As ADODB.Fields
Dim sDocumentPath As String
Dim objDocument As pkmcdo.KnowledgeDocument

sDocumentPath = FullName
Set objDocument = CreateDocument( _
sDocumentPath, _
f_sHref + "/" & RawName, _
"urn:content-classes:" & Profile)

With objDocument
.Categories = Array(":Briefs")
.Title = "New Document"
.Author = "Dave Sampieri"
.Property("urn:schemas-microsoft-com:office:office#Author1") = "DWS"
.Property("urn:schemas-microsoft-com:office:office#AuthorType") = Array("DistrictAttorney")
.Property("urn:schemas-microsoft-com:office:office#CaseNumber") = "90839403"
.Property("urn:schemas-microsoft-com:office:office#CourtType") = Array("SuperiorCourt")
.Property("urn:schemas-microsoft-com:office:office#DefendantName") = "Schmoe, Joe"
.Property("urn:schemas-microsoft-com:office:office#DocDate") = #2/2/2002#
.Property("urn:schemas-microsoft-com:office:office#PNumber") = "P-9283938"
.Description = "This is the description field"
.Keywords = Array("MegansLaw")

'This is the property that is not in the "Briefs" profile
.Property("urn:schemas-microsoft-com:office:office#OfficeDocType") = Array("Announcements")

.DataSource.Save
End With

Dim oVer As pkmcdo.KnowledgeVersion

Set oVer = New pkmcdo.KnowledgeVersion

oVer.Checkin objDocument
oVer.Publish objDocument

Set objDocument = Nothing
Set oVer = Nothing
End Sub

Dave Sampieri
SPSFAQ0301105 - Did anyone come across code to set the email accounts? Juby Vembenil - 0 Comments - stephencummins - Thu, Feb 20th, 2003 - Customisation
To my chagrin no one had anything to offer. I got some code working that might be of some help to some one that needs it. I got it working great on one workspace but for other workspaces on the same server it does nothing? Any suggestions will be greatly appreciated! Code needs server name and workspace name.

Here is the code:


On Error Resume Next

'For File System Object
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Const ADS_NAME_INITTYPE_GC = 3 ' VBScript cannot read.
Const ADS_NAME_TYPE_1779 = 1 ' Enumeration definition. Constant used for LDAP path
Const ADS_NAME_TYPE_NT4 = 3 ' Constant used for Winnt

' define constants for access to Web Store Folders
Const adModeUnknown = 0
Const adModeRead = 1
Const adModeWrite = 2
Const adModeReadWrite = 3
Const adModeShareDenyRead = 4
Const adModeShareDenyWrite = 8
Const adModeShareExclusive = 12
Const adModeShareDenyNone = 16

Const adCreateOverwrite = 67108864
Const adCreateCollection = 8192
Const adCreateNonCollection = 0

' Define Variables
Dim gStrDataSourceName
Dim gStrOutputFileName
Dim gStrErrorFileName
Dim gIntDay
Dim gIntMonth
Dim gIntYear
Dim gIntHour
Dim gIntMinute
Dim gIntSecond
Dim gStrMessage
Dim gStrOldEmail
Dim gStrNewEmail
Dim gStrUserId
Dim gStrServer
Dim gStrWorkspace
Dim gStrDelimiter

' Initializations
gIntDay = Day(Now())
gIntMonth = Month(Now())
gIntYear = Year(Now())
gIntHour = Hour(Now())
gIntMinute = Minute(Now())
gIntSecond = Second(Now())
gStrMessage = ""
gStrOldEmail = ""
gStrNewEmail = ""
gStrUserId = ""
gStrServer = ""
gStrWorkspace = ""
gStrDelimiter = "*"

Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set oArgs = wscript.arguments

' Start code
' Check the arguments passed in
If oArgs.Count <> 2 Then ' CR
WScript.Echo
Wscript.Echo "Usage : CSCRIPT setSharpointEmails.vbs server workspace"
WScript.Echo "eg : CSCRIPT setSharpointEmails.vbs w2lnsed1 im"
Wscript.Quit
Else
gStrServer = oArgs.item(0)
gStrWorkspace = oArgs.item(1)
gStrDataSourceName = "http://" & gStrServer & "/" & gStrWorkspace & "/system/users"
gStrOutputFileName = "Upd_" & gStrServer & "_" & gStrWorkspace & "_" & gIntYear & gIntMonth & gIntDay & "_" & gIntHour & gIntMinute & gIntSecond & ".log"
gStrErrorFileName = "Err_Upd_" & gStrServer & "_" & gStrWorkspace & "_" & gIntYear & gIntMonth & gIntDay & "_" & gIntHour & gIntMinute & gIntSecond & ".log"
subMain
End If
' End code

'Main Sub Code
Sub subMain()
set oFolder = CreateObject("Cdo.KnowledgeFolder")
set oUsers = CreateObject("Cdo.KnowledgeUser")
set RS = CreateObject("ADODB.RecordSet")

wscript.echo gStrDataSourceName

oFolder.DataSource.Open gStrDataSourceName, ,adModeReadWrite
Set RS = oFolder.Items
While not rs.eof ' Loop thru all approvers
oUsers.DataSource.Open gStrDataSourceName & "/" & rs.Fields.Item(0).value,,adModeReadWrite
' display of oUser.Name brings back format urn:users:Domain\user
' must use mid to get real domain\user
gStrUserId = mid(oUsers.name,11)
gStrOldEmail = oUsers.emailaddress

wscript.echo gStrUserId & gStrOldEmail

'Updating Process
gStrNewEmail = fncGetEmail(gStrUserId)
if (gStrNewEmail = "Error") or (gStrNewEmail = "") then
gStrMessage = "Error obtaining the correct user email from ldap for user : " & gStrUserId
Call subEchoFile (gStrMessage, gStrErrorFileName)
else
gStrMessage = "Updating:" & gStrDelimiter & "User=" & gStrUserId & gStrDelimiter & "Old Email=" & gStrOldEmail & gStrDelimiter & "New Email=" & gStrNewEmail
Call subEchoFile (gStrMessage, gStrOutputFileName)
oUsers.emailaddress = gStrNewEmail
oUsers.DataSource.Save
end if
gStrUserId = ""
gStrOldEmail = ""
gStrNewEmail = ""
rs.movenext
Wend

set rs = nothing
set oUsers = nothing
set oFolder = nothing
End Sub

' Functions and Subs
'from winnt to Ldap
Function fncGetLdap(pStrWinNt)
Dim vStrSid
Dim vStrQuery
Dim vStrServerName
Dim vObjConn
Dim vObjRecordSet
Dim vObjNameTranslation
Dim vObjResult

Set vObjNameTranslation = CreateObject("NameTranslate")
vObjNameTranslation.Init ADS_NAME_INITTYPE_GC, ""
vObjNameTranslation.Set ADS_NAME_TYPE_NT4, pStrWinNt
vObjResult = vObjNameTranslation.Get(ADS_NAME_TYPE_1779)
Set vObjNameTranslation = Nothing

fncGetLdap = vObjResult
End Function

Function fncGetEmail(pStrWinNt)
Dim vObjNameSpace
Dim vStrLdapPath
Dim vObjClassName
Dim vObjGroup

On Error Resume Next
vObjClassName = ""

vStrLdapPath = fncGetLdap(pStrWinNt)
Set vObjNameSpace = GetObject("LDAP://" & vStrLdapPath)
if Err.Number <> 0 then
Wscript.Echo Err.Num & " " & Err.Description
Err.Clear
fncGetEmail = "Error"
else
fncGetEmail = vObjNameSpace.mail
end if
End Function

Sub subEchoFile (ByVal pStrMessage, ByVal pStrFileName)
'Create Error Log File
Dim vObjFso
Dim vStrFile

Set vObjFso = CreateObject("Scripting.FileSystemObject")
Set vStrFile = vObjFso.OpenTextFile(pStrFileName, ForAppending, True)
vStrFile.WriteLine pStrMessage
vStrFile.Close
Set vStrFile = Nothing
Set vObjFso = Nothing
End Sub

Juby Vembenil
SPSFAQ0301103 - How to search across multiple content sources - 0 Comments - stephencummins - Mon, Feb 3rd, 2003 - Customisation
This attached file explains how you can customise SharePoint to do searches on more than one seperate Content Source. It's requires a lot of tweaking, so keep a copy of any file you modify!

Thanks to Weimin Changchien for all his excellent work on this and for sending it to me.

http://www.spsfaq.com/downloads/multiple_cs.zip
SPSFAQ0301102 - How Can I make a Web Part that displays a Shared Appointments Calendar/Contacts list? - 0 Comments - stephencummins - Mon, Feb 3rd, 2003 - Customisation
This question has been asked a thousand times on the Internet, but never answered in a detailed manner. Here is my shot at it:

DO NOT USE THE SMART OUTLOOK CALENDAR! This tool does not work inside of Sharepoint UNLESS you want it to connect to your Exchange Server 2000 Outlook Web

Access server. If the clients will be using Office XP, you can utilize the Microsoft Outlook Calendar web part available in the Webpart SDK. Typically, this

control is used to look at the logged-on users personal calendar. You need to modify the web part code to point it at a public folder. Once you import the

web part, click on it and choose "Show Advanced Settings". Scroll down to the "Embedded Content" section. Find the line that looks like this:

<String _locID="L_CalendarFolder_Text">Calendar</String>

Replace the text Calendar with the full path to your public folder, but... YOU MUST USE DOUBLE FORWARD SLASHES! As an example, I have a public calendar that

I am accessing with this web part - here is the line in my web part:

<String _locID="L_CalendarFolder_Text">\\Public Folders\\All Public Folders\\Sharepoint Test</String>

Notice that there are no quotes around the text!

Contacts works the same way - utilize the Outlook Contacts web part and replace the Contacts string with the pointer to your public folder:

<String _locID="L_ContactsFolder_Text">\\Public Folders\\All Public Folders\\Sharepoint Contacts</String>

If your clients are not using Office XP, you can use the Public Folders web part. It is not as advanced as the other web part, but it will allow you to

display the public folders and interact with them.

You can download it from http://www.SharepointCode.com

Dave Sampieri
SPSFAQ0301101 - Can I have a script that puts an array into the Categories and Keywords multivalue lists in SPS? - 0 Comments - stephencummins - Mon, Feb 3rd, 2003 - Customisation
This script splits the metatag value for Categories and Keywords into an array and then puts the array into the Categories and Keywords multivalue lists in SPS.

Thanks to Jason Sullivan.

colKeys = objMeta.Keys
For Each strKey in colKeys
vSPSProp = objMeta.Item(strKey)
vNewVal = objMetaVals.Item(strKey)
On Error Resume Next
objDocument.Property(vSPSProp) = vNewVal 'All other SPS properties aside from Keywords and Categories are text fields (strings)
If (Err.Number = -2147352571) Then 'Check for Type mismatch error - this happens if a string is assigned to a multivalue list in SPS
Err.clear
If UCase(strKey) = "CATEGORIES" Then
Dim DocCats, c
c = 0
objLogfile.Writeline "Document Categories are: "
DocCats = Split(vNewVal,";",-1,1) 'Split Categories using a ; as a delimeter
Do While c <= Ubound(DocCats)
DocCats(c) = Trim(DocCats(c))
objLogfile.Writeline Chr(9) & DocCats(c) 'Write the script actions to a log file for tracking
c = c + 1 Loop
objDocument.Categories = DocCats 'SPS Categories property is a Multivalue list (array)
End If
If UCase(strKey) = "KEYWORDS" Then
Dim KWords, k, SemiColon
k = 0
objLogfile.Writeline "Document Keywords are: "
SemiColon = Instr(1,vNewVal,";",1) 'Check if a ; is in the string
If SemiColon = 0 Then
KWords = Split(vNewVal," ",-1,1) 'Split keywords using a space as a delimeter
Else
KWords = Split(vNewVal,";",-1,1) 'Split keywords using a ; as a delimeter
End If
Do While k <= Ubound(KWords)
KWords(k) = Trim(KWords(k))
objLogfile.Writeline Chr(9) & KWords(k) 'Write the script actions to a log file for tracking
k = k + 1 Loop
objDocument.Keywords = KWords 'SPS Keywords property is a Multivalue list (array)
End If
End if
Next

objMeta is a dictionary object that was loaded with Metatag name and SPS property name pairs from an ini file that the script uses to configure itself.
This section of the ini file looks like:

DOCID=urn:schemas-microsoft-com:office:office#nresDocID
TITLE=urn:schemas-microsoft-com:office:office#Title
SUBJECT=urn:schemas-microsoft-com:office:office#Subject
AUTHOR=urn:schemas-microsoft-com:office:office#Author
MANAGER=urn:schemas-microsoft-com:office:office#Manager
COMPANY=urn:schemas-microsoft-com:office:office#Company
CATEGORIES=urn:schemas-microsoft-com:publishing:Categories
KEYWORDS=urn:schemas-microsoft-com:office:office#Keywords
DESCRIPTION=urn:schemas-microsoft-com:office:office#Description

objMetaVals is a dictionary object that holds metatag name (the key) and metatag values (the key value) read from the header of the HTML file.

Once an array is populated with the keywords or categories I just had to reference the array directly.

objDocument.Keywords = KWords (this works)

objDocument.Keywords = Array(KWords) (this doesn't work)

Page 11 of 24  -  Jump to: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

Search options
Search for
   
In fields
   
In category
   
Dated in
   

links
subscribe
Get the latest posts via email:

quick search
Search via Google:

random books


Copyright © SPSFAQ.com, Stephen Cummins Limited, All Rights Reserved