Click here to Skip to main content
15,896,450 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Populating the Treeview control in VB Pin
DaveAuld20-Apr-10 8:20
professionalDaveAuld20-Apr-10 8:20 
GeneralRe: Populating the Treeview control in VB Pin
ratbags20-Apr-10 10:02
ratbags20-Apr-10 10:02 
GeneralRe: Populating the Treeview control in VB Pin
DaveAuld20-Apr-10 19:15
professionalDaveAuld20-Apr-10 19:15 
GeneralRe: Populating the Treeview control in VB Pin
ratbags20-Apr-10 21:46
ratbags20-Apr-10 21:46 
GeneralRe: Populating the Treeview control in VB Pin
DaveAuld20-Apr-10 21:53
professionalDaveAuld20-Apr-10 21:53 
GeneralRe: Populating the Treeview control in VB Pin
ratbags21-Apr-10 0:23
ratbags21-Apr-10 0:23 
GeneralRe: Populating the Treeview control in VB Pin
DaveAuld20-Apr-10 3:49
professionalDaveAuld20-Apr-10 3:49 
QuestionMS Word and VB Webservices Pin
RossouwDB20-Apr-10 0:19
RossouwDB20-Apr-10 0:19 
Good day all,

I currently have a VB Webservice that opens, edits and saves an MS Word 2003 document via impersonation (my code is below, for those searching for impersonation techniques).

Everything works fine, what I would like to know is if there is a better way of manipulating an MS Word 2003 document without using impersonation? Due to security reasons, I am hoping to find a better way of approaching this.

I would highly appreciate it if you could help me out on this (if it is even possible!)

Thanks a lot
Rossouw de Bruin

Code:
' Values used by the LogonUser function's logonType parameter
  Public Enum LogonType
      LOGON32_LOGON_INTERACTIVE = 2
      LOGON32_LOGON_NETWORK = 3
      LOGON32_LOGON_BATCH = 4
      LOGON32_LOGON_SERVICE = 5
      LOGON32_LOGON_UNLOCK = 7
      LOGON32_LOGON_NETWORK_CLEARTEXT = 8
      LOGON32_LOGON_NEW_CREDENTIALS = 9
  End Enum

  ' Values used by the LogonUser function's logonProvider parameter
  Public Enum LogonProvider
      LOGON32_PROVIDER_DEFAULT = 0
      LOGON32_PROVIDER_WINNT35 = 1
      LOGON32_PROVIDER_WINNT40 = 2
      LOGON32_PROVIDER_WINNT50 = 3
  End Enum

  Declare Function LogonUser Lib "advapi32.dll" Alias "LogonUserA" ( _
                                                                      ByVal username As String, _
                                                                      ByVal domain As String, _
                                                                      ByVal password As String, _
                                                                      ByVal logonType As LogonType, _
                                                                      ByVal logonProvider As LogonProvider, _
                                                                      ByRef token As IntPtr _
                                                                    ) As Integer

  Public Sub LetterTemplate()
   Dim username As String = "username"
   Dim domain As String = "domain"
   Dim password As String = "password"

   ' A handle to the user who will be impersonated
   Dim token As IntPtr
   ' Log the user into Windows.
    Dim bLogonSuccessful As Boolean = Convert.ToBoolean( _
          LogonUser( _
          username, domain, password, _
          LogonType.LOGON32_LOGON_NETWORK, _
          LogonProvider.LOGON32_PROVIDER_DEFAULT, token))

   If Not bLogonSuccessful Then
     "Return something"
   End If

  ' Create a WindowsIdentity object that represents the logged-in user.
  Dim ident As New System.Security.Principal.WindowsIdentity(token)
  ' Impersonate the user.
  Dim ctx As System.Security.Principal.WindowsImpersonationContext = ident.Impersonate()

  '...... some other code

  'Release the impersonation
  ctx.Undo()
End Sub

AnswerRe: MS Word and VB Webservices Pin
Michel Godfroid20-Apr-10 0:53
Michel Godfroid20-Apr-10 0:53 
GeneralRe: MS Word and VB Webservices Pin
Michel Godfroid20-Apr-10 0:56
Michel Godfroid20-Apr-10 0:56 
QuestionCan visual basic be inserted in Dreamweaver? Pin
josephong19-Apr-10 22:11
josephong19-Apr-10 22:11 
AnswerRe: Can visual basic be inserted in Dreamweaver? Pin
Michel Godfroid20-Apr-10 0:38
Michel Godfroid20-Apr-10 0:38 
QuestionHelp in Crystal Report Selection Formula Pin
anandbpsri19-Apr-10 21:09
anandbpsri19-Apr-10 21:09 
QuestionCrystal report help Pin
anandbpsri19-Apr-10 21:05
anandbpsri19-Apr-10 21:05 
NewsCode Protection Pin
Oguz Bastemur19-Apr-10 13:50
Oguz Bastemur19-Apr-10 13:50 
GeneralRe: Code Protection Pin
Dalek Dave19-Apr-10 13:56
professionalDalek Dave19-Apr-10 13:56 
GeneralRe: Code Protection Pin
Oguz Bastemur19-Apr-10 14:52
Oguz Bastemur19-Apr-10 14:52 
GeneralRe: Code Protection Pin
_Damian S_19-Apr-10 15:56
professional_Damian S_19-Apr-10 15:56 
GeneralRe: Code Protection Pin
Paul Conrad20-Apr-10 6:51
professionalPaul Conrad20-Apr-10 6:51 
RantRe: Code Protection Pin
Ashfield20-Apr-10 9:07
Ashfield20-Apr-10 9:07 
QuestionSilverlight and VB.Net and VB Express question Pin
jerryj19-Apr-10 11:35
jerryj19-Apr-10 11:35 
AnswerRe: Silverlight and VB.Net and VB Express question Pin
Dalek Dave19-Apr-10 14:09
professionalDalek Dave19-Apr-10 14:09 
QuestionNew Application Advice Pin
programmervb.netc++19-Apr-10 8:15
programmervb.netc++19-Apr-10 8:15 
AnswerRe: New Application Advice Pin
programmervb.netc++21-Apr-10 11:57
programmervb.netc++21-Apr-10 11:57 
QuestionProblem with FormClosing event Pin
Yosh_19-Apr-10 5:39
professionalYosh_19-Apr-10 5:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.