Re: SPFileCollection , files.add method PROBLEMS



Try to impersonate as an admin. Even if you are using admin login,
impersonate as an admin explicitly. See the following post:

http://www.sharepointblogs.com/ssa/archive/2006/08/30/11624.aspx

Regards,

--
S.S. Ahmed
www.walisystems.com
<ilakidain@xxxxxxxxxxx> wrote in message
news:1157377361.719279.120960@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Hi Community

I have serius problem with the method "Add" from "SPFileCollection"

The matter:

If i use the parameters :
SPFile fichero = objCarpeta.Files.Add(strCarpetaLista +
strUrlRelativa,arrFichero,true);
it works perfectly but with the paremeters:
SPFile fichero = objCarpeta.Files.Add(strCarpetaLista +
strUrlRelativa,arrFichero,autor ,editor
,datFechaCreacion,datFechaModificacion);
NOT WORK ................ Show a message error:
" at Microsoft.SharePoint.h.a(UnauthorizedAccessException A_0)
at Microsoft.SharePoint.Library.a.a(String A_0, String A_1, Object
A_2, PutFileOpt A_3, String A_4, String A_5, Int32 A_6, Int32 A_7,
Object A_8, Object A_9)
at Microsoft.SharePoint.SPFileCollection.a(String A_0, Byte[] A_1,
PutFileOpt A_2, String A_3, String A_4, Int32 A_5, Int32 A_6, DateTime
A_7, DateTime A_8)
at Microsoft.SharePoint.SPFileCollection.Add(String strUrl, Byte[]
file, SPUser createdBy, SPUser modifiedBy, DateTime timeCreated,
DateTime timeLastModified)
at MigracionWinApp.Migracion.copiarelementosdoclibarbol(SPWeb objWeb,
Guid guidlista, String strTablaLista, Int32 idLista, Int32 tipolista)"


Some notes:
- it's a windows form application.
- The files adding in a area, the users "autor" y "editor" have the
permissos in area.
- the library (in the area) it's created previusly.
- all the parameters are Ok, the objects "autor" and "editor"user I
get with one function.
.
.
.
SPUser autor = ObtenerUsuario(objWeb,
CorregirDominioUsuario(strAutor));
SPUser editor =
ObtenerUsuario(objWeb,CorregirDominioUsuario(strEditor));
.
.
.

public SPUser ObtenerUsuario(SPWeb objWeb, string strUsuario)
{
PortalSite ps = tm.PortalSites[ new
Uri(ClassGeneral.strURL_WINDOWS_SHAREPOINT_SERVICES)];
Microsoft.SharePoint.Portal.PortalContext ctx =
Microsoft.SharePoint.Portal.PortalApplication.GetContext(ps);
Area homearea = AreaManager.GetArea (ctx,guiSubWebID); // guiSubWebID
se obtiene al pulsar sobre la libreria/area
SPUser usuariodev = homearea.Web.AllUsers[strUsuario];
}


Why fail ????
SPFile fichero = objCarpeta.Files.Add(strCarpetaLista +
strUrlRelativa,arrFichero,autor,editor,datFechaCreacion,datFechaModificacion);


Any help appreciated :-)


And thanks in advance.



.



Relevant Pages

  • Re: ImpersonateLoggedOnUser and SetFileAttributes
    ... admin and impersonate a non-admin account? ... Sebastian Bargmann ...
    (microsoft.public.win32.programmer.kernel)
  • Re: ASPNET permissions
    ... I dont want the aspnet account to be able to run as admin. ... > the best thing to do would be to impersonate to the admin account. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASPNET permissions
    ... I dont want the aspnet account to be able to run as admin. ... > the best thing to do would be to impersonate to the admin account. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Registry
    ... Writing HKEY_LOCAL_MACHINE woul require admin rights. ... If you know admin account you can impersonate as ...
    (borland.public.delphi.nativeapi)