Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / June 2005

Tip: Looking for answers? Try searching our database.

Help me get a pointer from a structure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
justengland@gmail.com - 21 Jun 2005 22:31 GMT
I am trying to use the LsaLogonUser API.  I am almost there.

'This is my structure
Public Structure MSV1_0_LM20_LOGON
Public MessageType As MSV1_0_PROTOCOL_MESSAGE_TYPE
Public LogonDomainName As String
Public UserName As String
Public Workstation As String
Public aryPassword As Char()        'Password
Public CaseSensitivePassword As String
Public CaseInsensitivePassword As String
Public ParameterControl As UInt32
End Structure

'API Call
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Assert,
Name:="FullTrust", Unrestricted:=True)> _
Declare Auto Function LsaLogonUser Lib "Secur32.dll" _
(ByVal LSA_Handle As IntPtr, _
ByRef OriginName As LSA_STRING, _
ByVal LogonType As SecurityLogonType, _
ByVal AuthenticationPackage As UInt32, _
ByVal AuthenticationInformation As IntPtr, _
ByVal AuthenticationInformationLength As UInt32, _
ByVal LocalGroups As IntPtr, _
ByRef SourceContext As TOKEN_SOURCE, _
ByRef ProfileBuffer As IntPtr, _
ByRef ProfileBufferLength As UInt32, _
ByRef logonid As Int64, _
ByRef Quotas As QUOTA_LIMITS, _
ByRef SubStatus As UInt16) _
As UInt16

I am passing the structure to AuthenticationInformation
I also need to be able to get the lenght as well

Thanks in advance
prakash - 22 Jun 2005 15:01 GMT
Try this codes...
---------------------------------------------------------------------------------------------
Imports System.Runtime.InteropServices

       Dim Cd As MSV1_0_LM20_LOGON
       Dim CdPointer As IntPtr
       Dim StructSize As Integer

       Marshal.StructureToPtr(Cd, CdPointer, True)
       StructSize = Marshal.SizeOf(GetType(MSV1_0_LM20_LOGON))
---------------------------------------------------------------------------------------------
regards
prakash
Justin - 22 Jun 2005 16:15 GMT
Close but but a little off I recieved an value cannot be null error.

This worked though
'Get a pointer to the above structure
'Build the    MSV1_0_LM20_LOGON structure
Dim LoginRequest As MSV1_0_LM20_LOGON
Dim ptrLoginRequest As New IntPtr
Dim lenLoginRequest As Integer

lenLoginRequest = Marshal.SizeOf(GetType(MSV1_0_LM20_LOGON))
ptrLoginRequest = Marshal.AllocCoTaskMem(lenLoginRequest)
Marshal.StructureToPtr(LoginRequest, ptrLoginRequest, True)

Thanks for your help           

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
prakash - 23 Jun 2005 05:39 GMT
most welcome

regards
prakash
justengland@gmail.com - 22 Jun 2005 16:12 GMT
            'Get a pointer to the above structure
            'Build the    MSV1_0_LM20_LOGON structure
            Dim LoginRequest As MSV1_0_LM20_LOGON
            Dim ptrLoginRequest As New IntPtr
            Dim lenLoginRequest As Integer

            lenLoginRequest = Marshal.SizeOf(GetType(MSV1_0_LM20_LOGON))
            ptrLoginRequest = Marshal.AllocCoTaskMem(lenLoginRequest)
            Marshal.StructureToPtr(LoginRequest, ptrLoginRequest, True)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.