473,385 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

MS Word and VB Webservices

14
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:
Expand|Select|Wrap|Line Numbers
  1.   ' Values used by the LogonUser function's logonType parameter
  2.     Public Enum LogonType
  3.         LOGON32_LOGON_INTERACTIVE = 2
  4.         LOGON32_LOGON_NETWORK = 3
  5.         LOGON32_LOGON_BATCH = 4
  6.         LOGON32_LOGON_SERVICE = 5
  7.         LOGON32_LOGON_UNLOCK = 7
  8.         LOGON32_LOGON_NETWORK_CLEARTEXT = 8
  9.         LOGON32_LOGON_NEW_CREDENTIALS = 9
  10.     End Enum
  11.  
  12.     ' Values used by the LogonUser function's logonProvider parameter
  13.     Public Enum LogonProvider
  14.         LOGON32_PROVIDER_DEFAULT = 0
  15.         LOGON32_PROVIDER_WINNT35 = 1
  16.         LOGON32_PROVIDER_WINNT40 = 2
  17.         LOGON32_PROVIDER_WINNT50 = 3
  18.     End Enum
  19.  
  20.     Declare Function LogonUser Lib "advapi32.dll" Alias _
  21.      "LogonUserA" ( ByVal username As String, _
  22.                             ByVal domain As String, _
  23.                             ByVal password As String, _
  24.                             ByVal logonType As LogonType, _
  25.                             ByVal logonProvider As LogonProvider, _
  26.                             ByRef token As IntPtr _
  27.                             ) As Integer
  28.  
  29.     Public Sub LetterTemplate()
  30.      Dim username As String = "username"
  31.      Dim domain As String = "domain"
  32.      Dim password As String = "password"
  33.  
  34.      ' A handle to the user who will be impersonated
  35.      Dim token As IntPtr
  36.      ' Log the user into Windows.
  37.       Dim bLogonSuccessful As Boolean = Convert.ToBoolean( _
  38.             LogonUser( _
  39.             username, domain, password, _
  40.             LogonType.LOGON32_LOGON_NETWORK, _
  41.             LogonProvider.LOGON32_PROVIDER_DEFAULT, token))
  42.  
  43.      If Not bLogonSuccessful Then
  44.        "Return something"
  45.      End If
  46.  
  47.     ' Create a WindowsIdentity object that represents the logged-in user.
  48.     Dim ident As New System.Security.Principal.WindowsIdentity(token)
  49.     ' Impersonate the user.
  50.     Dim ctx As System.Security.Principal.WindowsImpersonationContext = ident.Impersonate()   
  51.  
  52.     '...... some other code
  53.  
  54.     'Release the impersonation
  55.     ctx.Undo()
  56.   End Sub
  57.  
Apr 20 '10 #1
0 969

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jinashe | last post by:
what do i need to enable accessing of webservices from a clients PC i'm hosting some webservices from my server in VB.NET. i've got some client windows applications done in VB.NET. what have i...
1
by: Walter Levine | last post by:
I just worked through a VB.Net sample program that creates an rft document and then opens it in Word. The code that opens the document is: Dim sFileName As String sFileName = "Sample1.doc" ...
5
by: cyberstrike | last post by:
Hi guys, my company was wondering if it's possible to develop ASP.NET/Webservices easily using a IIS installed on a server instead of installing IIS locally on the development boxes. Can you...
2
by: Antuane | last post by:
any one have any idea how transactions could be enabled in webservices. i.e., suppose i've got 2 methods - one to add a contact, & the other to set some miscellaneous details for the contact, in a...
1
by: Mike | last post by:
Hi all, I have written a webservice which I am using in my smartphone applicaiton. I have tried the webservice with a WinForms client and it works time and time again perfectly. When I include...
8
by: Komandur Kannan | last post by:
We have a smart device application running on handhelds(Symbol MC9000G). The backend is Oracle and a middle tier web services development done in Vb.net. We use pessimistic Locking due to...
0
by: Federico | last post by:
Hi I want to create a Web Services where I receive a Template DOT word a file XML and with these I create a Document that a I'll Send as Dime Attachment. <WebMethod()> _ Public Function...
5
by: ChrisM | last post by:
Hi, I have written a stand alone WinForms application with an MS Access back-end for the (small)company I work for. They are now talking about moving a part of their operations into a second...
1
by: Darsin | last post by:
What i am doing is to pull the data from a CMS and import it to Word 2007 Beta and i also have to export the data from Word 2007 Beta back to that CMS. We have with us two Web Services of the CMS....
6
by: yootaeho | last post by:
Hi all, Does anyone know that there is PDF conversion component from MS word for ASP.NET? I know that there are a number of commecial PDF conversion programs but I just wonder if there are free...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.