Need help with file CheckIn

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
jromb_trc

Need help with file CheckIn

Post by jromb_trc » Fri Mar 11, 2005 6:21 pm

I am having problems file checkins in the code below. It works fine if we are using it in a window app but when using it in our asp.net website it will not check in a file. I have tried the exact same file in the same folder using the same user permissions. Can someone help?

Using Vault 2.0.6

Public Function CheckIn(ByVal strVaultFile As String, Optional ByVal strLocalPath As String = "", Optional ByVal strComment As String = "") As ResultCode
Dim vcfile As VaultClientFile
Dim csi As ChangeSetItem
Dim csic As ChangeSetItemColl
Dim csicNew As New ChangeSetItemColl
Dim Result As ResultCode

vcfile = _ci.TreeCache.Repository.Root.FindFileRecursive(strVaultFile)

If Not (vcfile Is Nothing) Then
SetWorkingFolder(vcfile.Parent.FullPath, strLocalPath)

csic = _ci.InternalChangeSet_GetItems(True)
For Each csi In csic
If csi.DisplayRepositoryPath.ToLower = strVaultFile.ToLower Then
csicNew.Add(csi)
End If
Next

If csicNew.Count > 0 Then
Result = _ci.Commit(csicNew)
Else
If _ci.UndoCheckOut(vcfile, LocalCopyType.Leave) Then
Result = ResultCode.CheckInUnDone
End If
End If
Else
Throw New Exception(String.Format("{0} was not found in Vault.", strVaultFile))
End If

RestoreWorkingFolder(vcfile.Parent.FullPath)

Return Result
End Function

Public Function SetWorkingFolder(ByVal strVaultFolder As String, ByVal strWorkingFolder As String) As Boolean
Dim bResult As Boolean = False
Dim stackFolders As Stack

If strWorkingFolder <> "" And IO.Directory.Exists(strWorkingFolder) Then
If lstOldWorkingFolders(strVaultFolder) Is Nothing Then
stackFolders = New Stack
lstOldWorkingFolders.Add(strVaultFolder, stackFolders)
Else
stackFolders = lstOldWorkingFolders(strVaultFolder)
End If

If _ci.TreeCache.GetWorkingFolder(strVaultFolder) = "" Then
stackFolders.Push("REMOVE")
Else
stackFolders.Push(_ci.TreeCache.GetWorkingFolder(strVaultFolder))
End If
_ci.TreeCache.SetWorkingFolder(strVaultFolder, strWorkingFolder)
_ci.Refresh()
bResult = True
End If

Return bResult
End Function

Public Function RestoreWorkingFolder(ByVal strVaultFolder As String) As Boolean
Dim bResult As Boolean = False
Dim stackFolders As Stack, strOldFolder As String
stackFolders = lstOldWorkingFolders(strVaultFolder)

If Not (stackFolders Is Nothing) Then
strOldFolder = stackFolders.Pop()
If strOldFolder = "REMOVE" Then
_ci.TreeCache.RemoveWorkingFolder(strVaultFolder)
Else
_ci.TreeCache.SetWorkingFolder(strVaultFolder, strOldFolder)
End If
_ci.Refresh()
bResult = True
End If

Return bResult
End Function

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Fri Mar 11, 2005 8:18 pm

Is it an impersonation issue? By default, asp.net apps run as the MACHINE\ASPNET or NT AUTHORITY\NETWORK SERVICE user, which have restricted permissions. Try setting impersonation in your web.config to a normal user.

jromb_trc

Need help with file CheckIn

Post by jromb_trc » Mon Mar 14, 2005 10:28 am

We don't think it's a permissions problem as the pages that use this code are in our intranet which is using Window Authentication for access. Also using the same login we can do all the other functions in Vault, checkout, getlatest, undo checkout, ...

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Mon Mar 14, 2005 10:37 am

If you're using Windows Auth for the web app, do you have <identity impersonate="true"/> in your web.config? This will make every request use the account of the user who is making the web request.

Can you give me more information as to which line in your sample code is failing?

jromb_trc

Need help with file CheckIn

Post by jromb_trc » Mon Mar 14, 2005 12:20 pm

We have had impersonation turned on. Here are the lines from our web.config file:

<authentication mode="Windows" />
<identity impersonate="true" />

The line that is failing is:

csic = _ci.InternalChangeSet_GetItems(True)

Its returning ChangeSetItems in the Windows app and no ChangeSetItems in the web app.

Thanks for your help.

jeremy_sg
Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear
Contact:

Post by jeremy_sg » Mon Mar 14, 2005 1:27 pm

I think that I need more information from you. Please email me using the button below this post.

Post Reply