Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Single Signon Problem. please help

Status
Not open for further replies.

PaulPierce

Programmer
Aug 10, 2004
2
GB
I am trying to get a global task webpart working, taken
from the book "Microsoft sharepoint Building Office 2003
Solutions" by Scot P Hillier
I am developing on a win2k3 server with visual studio
compiling straight into the bin directory.

The problem occurs in the following code when the
createIdentity function is called

'Context for the new identity
Dim objContext As WindowsImpersonationContext
Dim arrCredentials() As String
Dim strUID As String
Dim strDomain As String
Dim strPassword As String
Dim objDataSet As DataSet

Try

'Try to get credentials
Credentials.GetCredentials(Convert.ToUInt32
("0"), "SPSAuthority", arrCredentials)
strUID = arrCredentials(0)
strDomain = arrCredentials(1)
strPassword = arrCredentials(2)
'Change the context
Dim objIdentity As WindowsIdentity

'objIdentity.GetCurrent()
objIdentity = CreateIdentity(strUID, strDomain,
strPassword)
objContext = objIdentity.Impersonate

Catch x As SingleSignonException
lblMessage.Text += "No credentials available." + vbCrLf
Catch x As Exception
lblMessage.Text += x.Message + vbCrLf
End Try



The debugger will not allow me to step into the
CreateIdentity function listed below,
a "System.Security.Permissions.SecurityPermission"
exception is caught.
I have tried to execute the code in both a windows
appliction and a asp.net web application without any
problems so conclude that it must be due to a sharepoint
configuration problem.


Protected Shared Function CreateIdentity(ByVal User As
String, ByVal Domain As String, ByVal Password As String)
As WindowsIdentity

Dim objToken As New IntPtr(0)
Dim ID As WindowsIdentity
Const LOGON32_PROVIDER_DEFAULT As Integer = 0
Const LOGON32_LOGON_NETWORK As Integer = 3

'Initialize token object
objToken = IntPtr.Zero

' Attempt to log on
Dim blnReturn As Boolean = LogonUser(User, Domain,
Password, LOGON32_LOGON_NETWORK,
LOGON32_PROVIDER_DEFAULT, objToken)

'Check for failure
If blnReturn = False Then
Dim intCode As Integer = Marshal.GetLastWin32Error()
Throw New Exception("Logon failed: " & intCode.ToString)
End If

' 'Return new token
ID = New WindowsIdentity(objToken)
CloseHandle(objToken)
Return ID

End Function

<DllImport("advapi32.dll", SetLastError:=True)> _
Private Shared Function LogonUser(ByVal lpszUsername As
String, _
ByVal lpszDomain As String, _
ByVal lpszPassword As String, ByVal dwLogonType As
Integer, _
ByVal dwLogonProvider As Integer, _
ByRef phToken As IntPtr) As Boolean
End Function



The following error is reported to the Application event
log.

The Microsoft Single Sign-on (SSOSrv) service failed to
retrieve credentials for user NT AUTHORITY\NETWORK
SERVICE, enterprise application definition SPSAuthority.
The error returned was 0x80630001.

Any help with this would be much appreciated

Thanks in Advance Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top