Regarding Server object Model in Custom Windows service

Hi,
I am writing a custom windows service to update the Sharepoint 2013 list every morning. But when i am try to create a SPSite object by passing the SITE URL it is throwing the below error.
Code :
using(SPSite site = new SPSite(SITE_URL))
Error :
"The Web application at "" could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application."
Even though the SITE URL is correct. It working while browsing in explorer. 
Not sure why it is happening. 
Thanks.
Akhilesh Rao

Hi Akhilesh,
Please try to add yourself to the WSS_ADMIN_WPG group on the server.
Or here are the most common reasons this error can occur:
1.The code is executed on a different machine - The SharePoint object model (except the Client API) requires to be run on the SharePoint server itself. It is not possible to run the application on a server which is not within the same SharePoint farm the
code is trying to access.
2.Insufficient Rights on the site collection - The code is executed in context of an account which does not have read permission on the site collection
3.Incorrect Url being used - Verify that the site works correct in a browser and double check that the server is correct registered in the AAM settings
4.Incorrect bitness - The SharePoint object model needs to be executed with the same bitness as the operating system. That means you cannot use the SharePoint object model in a 32-bit application if the Operating System and SharePoint are installed as 64-bit
version. Ensure to compile the project using the correct bitness (64-bit on a 64-bit machine vs. 32-bit on a 32-bit machine)
5.Incorrect .NET framework version -  Ensure that the project is configured to use .NET 3.5 for SharePoint 2010 and below and .NET 4.0 for SharePoint 2013
Best Regards
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected]

Similar Messages

  • Create a site collection with dedicated content db with the help of server object model

    Hi,
     I have a requirement to implement a create a new site collection with dedicated content db. i have got 2 PowerShell scripts which does the same. first i will  create a content  db and then create the sitecollection with contentdb
    parameter with the created contentdb name.
    Now the site collection created must contain few doc libs and few splists with look up columns, people picker data type, multiline of text, single line of text,choice field. hence i am thinking the below approach:
     1) create a web template and include sp doclibs, splists , site columns in this.
     2) i am thinking of a ui design to create the below:
     These are called "projects" which is actually the site collection with the doclibs, splists and must be created by sharepoint admin on click of a link in my landing page.end users access these "projects"  aka 
    "site collections" and uploads the documents into these projects and collaborate.
    so my question is :  On click of a button can I create a site collection with a dedicated content db based on the web template created with the  hel of  server  object model?
    The other approach is on click of this button call the power shell script which accepts the sitecollection name and contentdb name as parameter. is this possible in  server obj.model ?
    passing a paramter from code behind- visual web part ui to power shell ?
    and it should create the site collec based on the web template and create the content db.
    my doubt #3 : will it not throw error "request timed out" when creating the site collec and contentdb from ui ?

    Try below:
    http://sharepoint.stackexchange.com/questions/21606/programmatically-create-a-site-collection-in-an-existing-mounted-content-databa
    PowerShell is just a wrapper for the object model. You shouldn't need to reference PowerShell in your feature, just create the new site collection with C# inside your feature. There's a blog post here that illustrates some code that may get you started.
    http://blog.mastykarz.nl/programmatically-creating-sites-site-collections-custom-web-template/
    http://blogs.msdn.com/b/vesku/archive/2014/06/09/provisioning-site-collections-using-sp-app-model-in-on-premises-with-just-csom.aspx
    # Enable the remote site collection creation for on-prem in web application level
    # If this is not done, unknon object exception is raised by the CSOM code
    $WebApplicationUrl = http://dev.contoso.com
    $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
    if ($snapin -eq $null)
    Write-Host "Loading SharePoint Powershell Snapin"
    Add-PSSnapin "Microsoft.SharePoint.Powershell"
    $webapp=Get-SPWebApplication $WebApplicationUrl
    $newProxyLibrary = New-Object "Microsoft.SharePoint.Administration.SPClientCallableProxyLibrary"
    $newProxyLibrary.AssemblyName = "Microsoft.Online.SharePoint.Dedicated.TenantAdmin.ServerStub, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
    $newProxyLibrary.SupportAppAuthentication = $true
    $webapp.ClientCallableSettings.ProxyLibraries.Add($newProxyLibrary)
    $webapp.Update()
    Write-Host "Successfully added TenantAdmin ServerStub to ClientCallableProxyLibrary."
    # Reset the memory of the web application
    Write-Host "IISReset..."
    Restart-Service W3SVC,WAS -force
    Write-Host "IISReset complete."
    If this helped you resolve your issue, please mark it Answered

  • Getting 'File not found' error while using server object model code

    Hi,
    I am using server object model code to pull list data in a console application. My machine has standalone installation of SP 2010. I am getting error 'File Not Found', however the same operation is working fine with client object model code.
    Code I am using:
    string strURL=http://servername/sites/sitename;
    SPSite siteObj=new SPSite (strURL); //getting error here.
    I have already checked the below,
    1. Framework being used is 3.5.
    2. I have proper access to site.
    3. Running visual studio as admin.
    Any help is much appreciated.
    thanks
    Tarique
    thanks and regards Tarique Aslam

    Hello Tarique ,
    Couple of pints need to check:
    1. User running the console application needs to have at least read permission to the SharePoint databases
    2. Set application by changing the "Platform target:" option on the "Build" to "Any CPU"
    Also refer this similar thread:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/2a419663-c6bc-4f6f-841b-75aeb9dd053d/spsite-file-not-found
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Can we write client object model code with Server object model?

    Hi everyone,
    I have to create one timer job using client object model (C#) in Sharepoint 2010 template on feature activation. Is it possible to write the code of client object in sharepoint empty project to create timer job? If yes/no? then why?
    Thanks in advance!!!

    Hi ShindeK,
    Yes you can used CSOM in Sharepoint but Timer jobs run directly on the server. The Client Side Object Model is a wrapper that brokers its calls to the server via the built in web services that SharePoint provides.
    You will not get any performance gains in this scenario using CSOM. You should use the full server object model of SharePoint
    SharePoint 2010 also has three Client Object Models (Managed, Silverlight, JavaScript) which are meant to be used by code accessing SharePoint remotely.
    --You can also used powershell script in timer job
    Chekc the link which cann help you step by step CSOM in Sharepoint timer job
    http://www.youtube.com/watch?v=Z7wHj-bSk0g
    You can also try the below link....
    https://bramdejager.wordpress.com/2013/08/02/using-csom-and-powershell-to-query-sharepoint-online-or-on-premise/
    http://stackoverflow.com/questions/3656920/run-sharepoint-timer-jobs-from-powershell
    Please mark the Answer and Vote me if you think that it will help you to resolved your issue

  • Server Object model Vs Search object model

    Hi ,
    Is it preferred to use sharepoint sever object (powershell) model over Search object model for large data
    as search has dependency on crawling.
    Swati
    SP Page: http://www.facebook.com/SharePointQ SP Blog: http://swatipoint.blogspot.com

    Hi,
    Are you looking for server side object model vs Client side model?
    If yes, 
    Deciding Which SharePoint 2010 API to Use
    https://msdn.microsoft.com/en-us/library/office/hh313619(v=office.14).aspx
    please let us know , if not otherwise
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • How to retrive list item form sub folder (sub folders) in sharepoint using CAML or Server Object Model?

    Hi All,
    I have multiple folders in document library.I want to retrive list item form folder.
    Following is snap
    I want to get all sub folder and list item in
    Sub folder 1.
    Any will be help appreciated..
    Thanks
    Balaji More

    Hi Balaji,
    If
    you want to query all folders and sub folders of a list or document library, you have to define extra query options. If you are working with the object model you have to set the
    ViewAttributes property of the SPQuery object as follows:
    qry.ViewAttributes = "Scope='Recursive'";
    you can use the client 0bject model to get this as well
    ClientContext clientContextObj =
    new ClientContext("http://Servername/");
    List yourDocLib = clientContextObj.Web.Lists.GetByTitle("Shared Documents");
    CamlQuery camlQueryObj = new CamlQuery();
    camlQueryObj.ViewXml =
    @"<View Scope='Recursive' />";
    ClientOM.ListItemCollection listItems =
    yourDocLib.GetItems(camlQuery);
    clientContextObj.Load(listItems);
    clientContextObj.ExecuteQuery();
    foreach (var item in listItems)
    Krishana Kumar http://www.mosstechnet-kk.com

  • How to show data from sharepoint list in mm dd yyyy format using Server Object Model

    In SharePoint 2010
    List "Employee", Colum Name "JoinDate" 
    has stored data in  (01/31/2014 12.00 PM) mm\dd\yyyy hr:mm PM format.
    How to display this data in mm\dd\yyyy only using C# on custom web part?

    //Write the code to read your list item
    SPListItem item = list.Items[0];
    //Get a DateTime object with the list column value
    DateTime date = Convert.ToDateTime(item["Date Column Name"]);
    String strDate = date.ToString("mm-dd-yyyy hh:mm tt");
    //you can also try ("dd/mmm/yyyy")
    http://sharepoint.stackexchange.com/questions/12820/safest-way-to-get-a-date-from-sharepoint-into-a-c-datetime-field-using-object

  • Determine current Page's Context Navigation Term using server object model

    I am trying to find a way to figure out the navigation term in the context of page processing that was requested through a friendly url.  I cannot seem to locate anything on MSDN.  The only similar functionality i see is using CSOM via _spFriendlyUrlPageContextInfo.
     

    Hi,
    Please refer to the following article, it has information how to get the friendly URL
    How to get friendly URL of the current page in Sharepoint programmatically
    Please don't forget to mark it answered, if your problem resolved or helpful.

  • Custom wcf service that uses SharePoint Object Model.

    Hi All,
    I am writing a custom service on SharePoint. I have noticed most of the people do deploy the custom wcf service in layout folder in 12/14/15 hive. I am wondering is it mandatory? Can’t we deploy the custom wcf service that uses SharePoint Object Model as
    virtual directory on a specific port?
    Regards Restless Spirit

    It is suggested to use WCF in 12/14/15 hive folder due to security and eas in use. Check below
    http://www.dotnetcurry.com/showarticle.aspx?ID=760
    http://msdn.microsoft.com/en-us/library/office/ff521584%28v=office.14%29.aspx
    http://stackoverflow.com/questions/16008593/where-should-custom-wcf-service-for-sharepoint-2010-resides
    If you want to use the server object model you have to host your WCF service on the same server as your SharePoint is installed on.
    If the WCF service has to be on a different server you can use the client object model or the SharePoint webservices to communicate to SharePoint.
    (link to a question about using server object model on different server
    http://nikpatel.net/2012/02/29/step-by-step-building-custom-wcf-services-hosted-in-sharepoint-part-i/

  • Questions about Windows services on a OS X 10.3 server

    Hi! I'm wanting to configure an OS X 10.3 server to participate in a Windows workgroup so I can share a directory on the server that the Windows machine can use as a backup drive, of sorts. I've got only ONE Windows box in an all-Mac network. The ultimate goal is to provide an automated backup solution for the Windows machine. I would like the Windows user to copy their files to the server so the scheduled Backup running on the server will backup their files, along with the rest of the files that are backed up to iDisk.
    So, I'm thinking I can use the Windows service on the OS X server to provide the backup directory/folder the Windows machine will map to a local windows drive, making it easy to copy files to the target backup area.
    I've got AFP, OpenDirectory (I think), and Windows service as the only services running on the OS X server. I've got the Windows service setup as a standalone server with the correct workgroup name and the Windows machine is setup with the same workgroup as the server. The Windows machine is running Windows XP.
    I've got the Windows service setup to act as the workgroup browse master and I do NOT have WINS enabled.
    Now for my questions:
    When I view the workgroup on the server in the "Network" area of Finder, I see nothing. When I view the workgroup on the Windows machine, I only see the Windows machine. On the server, I turned on the Windows service log and noticed only SMBD was starting, not NMBD. I presume this is why the server can't "see" the Windows machine and vice-versa, correct?
    I've read the following threads:
    http://discussions.apple.com/thread.jspa?messageID=2358362&#2358362
    http://discussions.apple.com/thread.jspa?messageID=4132419&#4132419
    and it looks like I need to create an account for the Windows user on the OS X server and I'm thinking I need to use the "Workgroup Manager" for that, right?
    There are no passwords for the Windows accounts that would be connecting to the same backup area on the server. Will I be able to create accounts without passwords on the server for these users or will I be required to specify a password for when the Windows machine connects to the server?
    This is my first time configuring an OS X server like this so please excuse my elementary questions.
    Thanks!
    Peace...

    You need to make sure the shortname in workgroup manager is the same as the logon name when you create the drive on the PC.
    Personally i'd do it all over IP. On the PC goto Run, and type \\ip address of server\sharename. It should then ask for a UN/PW, this is what you've entered into workgroup manager, and should be the shortname.
    That should then give you the drive.
    To map it so its always there when they log-in, goto my computer and map network drive, making sure you click the link that says 'use a different account to connect'

  • Windows Services don't show as started in Server Manager

    Server manager does not show Windows services as being started on one of our xserves - although Samba is up and operational just fine.
    Even after re-starting the server after we moved a month or so ago it has not shown windows as being started. Samba came up ok after reboot with no intervention.
    Here's the processes and PIDs:
    xserve1:/var/run root# more smbd.pid
    853
    xserve1:/var/run root# ps ax | grep 853
    8432 p2 R+ 0:00.00 grep 853
    xserve1:/var/run root# more nmbd.pid
    24215
    xserve1:/var/run root# ps ax | grep 24215
    24215 ?? Ss 0:16.63 /usr/sbin/nmbd -D
    8441 p2 R+ 0:00.00 grep 24215
    Not sure how to recalibrate Server Manager to recognise that the service is actually running.
    Any clues?
    Thanks,
    Campbell
    XServes   Mac OS X (10.4.5)   12 Macs & several hundred too many PCs

    That happened to me after the update to 10.4.4 and the issue was that somehow com.apple.smbd got set back to start in launchctl.
    To see if this is your issue, run this command
    Code:
    ps alx | grep mbd
    You will probably notice that there are not just one each of SMBD and NMBD but one of them has 2 processes. In my case it was like this
    0 10269 1 0 31 0 30664 328 - S ?? 0:00.00 /usr/sbin/smbd -D
    0 10275 1 0 31 0 28464 684 - Ss ?? 0:00.01 /usr/sbin/nmbd -D
    0 10277 10275 0 31 0 28452 184 - S ?? 0:00.00 /usr/sbin/nmbd -D
    501 10284 1959 0 31 0 27820 4 - R+ p1 0:00.00 grep mbd
    Your post about smbd.pid being the 'wrong' one is the hint that this is going on.
    So next run this
    Code:
    sudo launchctl list
    and if you see in that list this
    org.samba.smbd
    you have the same issue. So to stop this I ran a GUI program called Lingon to unload and disable the offending plist (called smbd.plist in /System/Library/LaunchDaemons) but I think you can run the following to do the same thing
    Code:
    sudo launchctl unload -w org.samba.smbd
    Peter
    PowerMac G5 Dual 2.5Ghz   Mac OS X (10.4.5)   Server

  • Problem: Deployment to WL10.3 Server Instance started as Windows Service

    Hi Everybody,
    I have deployed my J2EE Application to a Standalone WebLogic Server Instance (in development mode) started from the Windows Command Level via startWebLogic.cmd. I also tested the deployment to a Clustered Managed Server Environment(1 AdminServer+2 MS Servers in the cluster; development mode), all servers started from the command line. The application could be tested and everything worked fine.
    But:
    When I set up the WebLogic Server Instance(s) as a Windows Service(s) (following the instructions http://e-docs.bea.com/wls/docs103/server_start/winservice.html) my application can’t be deployed at startup time.
    I get 3 ClassNotFoundExceptions:
    - on startup class "DMS-Startup" (oracle.dms.wls.DMSStartup)
    - on startup class "ODL-Startup" (oracle.core.ojdl.weblogic.ODLConfiguration)
    - on startup class "JPS Startup Class" (oracle.security.jps.wls.JpsWlsStartupClass)
    The Service is started but under Administration Console/Deployments the Enterprise Application is marked as “New” and not as “ Active”. The other Deployments: adf.oracle.domain(1.0, 11.1.1.0.0), jsf(1.2, 1.2.7.1) and jstl(1.2, 1.2.0.1) are shown as “Active”.
    I tried to redeploy the Application directly from the JDeveloper to the running Standalone WLS Instance (Single Server) - as I did before.
    The Deployment failed:
    [Deployer:149034]An exception occurred for task [Deployer:149026]deploy application ... on AdminServer.: .
    weblogic.management.DeploymentException:
    #### Deployment incomplete.
    #### Nov 25, 2008 9:58:53 PM
    Deployment Failed
    Why does the deployment work on the WLS Instance started from command line and why does it fail when started as Windows Service?
    I am Using WLServer 10.3 and the JDeveloper 11g on a Windows Vista OS - both installed via jdevstudio11110install.exe. My Web Application uses BC and ADF Faces.
    The Windows Service is set up by doing the following in a server-specific script placed under the USERDOMAIN_HOME directory:
    set DOMAIN_NAME=mydomain
    set USERDOMAIN_HOME=C:\Oracle\Middleware\user_projects\domains\mydomain
    set JAVA_OPTIONS=Dweblogic.Stdout = … Dweblogic.Stderr=…
    set MEM_ARGS=-Xms40m –Xmx250m
    call "C:\Oracle\Middleware\wlserver_10.3\server\bin\installSvc.cmd"
    And there’s one more problem with the Windows Service:
    I’m not able to Uninstall the service from a server-specific script, first setting the DOMAIN_NAME and the SERVER_NAME=AdminServer and than
    using call "C:\Oracle\Middleware\wlserver_10.3\server\bin\uninstallSvc.cmd".
    I must do this directly in the registry.
    Is anything missing? What’s wrong?
    Please help!
    Thanks
    Anita
    Edited by: user586097 on 26.11.2008 11:55
    Edited by: user586097 on 26.11.2008 12:00
    Edited by: user586097 on 26.11.2008 12:02

    This thread was very helpful to get WebLogic 11g running as a Windows service. My problem was that I couldn't get the Enterprise Manager application to deploy correctly on startup, so I had to tweak both the installSvc.cmd and my script that installs the service (by copying important Java Options from the startup script that works as noted above). It was too hard to discern what exactly Enterprise Manager needed, so I copied a whole bunch.
    What I ended up doing was using this as a script to install the Windows service:
    echo off
    SETLOCAL
    set DOMAIN_NAME=base_domain
    set USERDOMAIN_HOME=C:\Oracle\Middleware\user_projects\domains\base_domain
    set SERVER_NAME=AdminServer
    set PRODUCTION_MODE=false
    set JAVA_OPTIONS=-client -Xms512m -Xmx1024m -XX:CompileThreshold=8000 -XX:PermSize=128m -XX:MaxPermSize=256m -Dweblogic.Name=AdminServer -Djava.security.policy=C:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\weblogic.policy -Xverify:none -da -Dplatform.home=C:\Oracle\MIDDLE~1\WLSERV~1.3 -Dwls.home=C:\Oracle\MIDDLE~1\WLSERV~1.3\server -Dweblogic.home=C:\Oracle\MIDDLE~1\WLSERV~1.3\server -Ddomain.home=C:\Oracle\MIDDLE~1\USER_P~1\domains\BASE_D~1 -Doracle.home=C:\Oracle\MIDDLE~1\ORACLE~1 -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Djrockit.optfile=C:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.jrf_11.1.1\jrocket_optfile.txt -Doracle.security.jps.config=C:\Oracle\MIDDLE~1\USER_P~1\domains\BASE_D~1\config\fmwconfig\jps-config.xml -Djava.protocol.handler.pkgs=oracle.mds.net.protocol -Dweblogic.alternateTypesDirectory=C:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.ossoiap_11.1.1,C:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.oamprovider_11.1.1 -Dsso.filter.enable=true -DUSE_JAAS=false -Djps.policystore.hybrid.mode=false -Djps.combiner.optimize.lazyeval=true -Djps.combiner.optimize=true -Djps.auth=ACC -noverify -Doracle.core.ojdl.logging.usercontextprovider=oracle.core.ojdl.logging.impl.UserContextImpl -Dtangosol.coherence.log=jdk -Dwc.oracle.home=C:\Oracle\Middleware\Oracle_WC1 -DjiveHome=C:\Oracle\MIDDLE~1\USER_P~1\domains\BASE_D~1\config\fmwconfig\servers\AdminServer\owc_discussions_11.1.1.1.0 -Dtangosol.coherence.log=jdk -Doracle.core.ojdl.logging.usercontextprovider=oracle.core.ojdl.logging.impl.UserContextImpl -Doracle.mds.bypassCustRestrict=true -Djava.awt.headless=true -XX:+UseParallelGC -XX:+DisableExplicitGC -Dem.oracle.home=C:\Oracle\Middleware\Oracle_WC1 -Djava.awt.headless=true -Dweblogic.management.discover=true -Dwlw.iterativeDev= -Dwlw.testConsole= -Dwlw.logErrorsToConsole= -Dweblogic.ext.dirs=C:\Oracle\MIDDLE~1\patch_wls1031\profiles\default\sysext_manifest_classpath
    call "C:\Oracle\Middleware\wlserver_10.3\server\bin\installSvc.cmd"
    ENDLOCAL
    and slightly modifying my installSvc.cmd to:
    set CLASSPATH=%WEBLOGIC_CLASSPATH%;%CLASSPATH%;C:\Oracle\MIDDLE~1\ORACLE~1\soa\modules\commons-cli-1.1.jar;C:\Oracle\MIDDLE~1\ORACLE~1\soa\modules\oracle.soa.mgmt_11.1.1\soa-infra-mgmt.jar;C:\Oracle\Middleware\Oracle_WC1\webcenter\modules\oracle.portlet.server_11.1.1\oracle-portlet-api.jar;C:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.jrf_11.1.1\jrf.jar;C:\Oracle\MIDDLE~1\WLSERV~1.3\common\eval\pointbase\lib\pbclient57.jar;C:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\xqrl.jar
    It needed those extra .jars to deploy properly.
    Edited by: user11090163 on Sep 2, 2009 9:04 AM

  • How to set Essbase Administration Server as Windows service?

    Hi,I have installed the Essbase Admin Services 7.1.0.0 Build 261 under Tomcat application server. Now from Start menu I have to select "Start Administration Server". Is there any way to set this option as Windows Service.My system:Windows 2003 SP1,Essbase 7.1.0,Essbase Admin Services 7.1.0.0 Build 261Thanks,Grofaty

    This information is in the Install Guide that comes with EAS.Running EAS as a Windows service is an option you can select when you install it. If you did not do that, you can set it up to run as service by doing the following: (From the EAS Install Guide)----------------------------------------Adding Administration Server as a Windows ServiceYou can add Administration Server as a Windows service, even if it was not installed as a Windows service.?To add Administration Server to the list of Windows services:1. From a command prompt, navigate to the following directory: EASPATH\eas\server\bin2. Run the following command: install_service.batAdministration Services installs the Windows service as Hyperion-Essbase_Administration_Server Windows service. A message displayed in the command prompt window indicates that the service is installed.3. Start the Hyperion-Essbase_Administration_Server Windows service. See ?Starting the Administration Server Windows Service? on page 49.The Hyperion-Essbase_Administration_Server Windows service is set to start automatically each time you reboot.

  • How to impersonate in client Object model?

    Hii,
    I am using client Object Model Programming in WCF service which is hosted on IIS. I have created separate APP pool in IIS which has windows authentication enabled. This App pool account will be dealing with the sharepoint server. Now I am stuck at one point.when
    I upload a file, I want to set the actual logged in user as the author or editor of the file not the app pool account. Means I want to impersonate. How can I do this?
    I have visited this link
    http://stackoverflow.com/questions/949340/getting-networkcredential-for-current-user-c but didnt work out as expected. Can any one provide some input please?
    Thanks and Regards,
    PraTech

    Hi I have tried both the options.
    The first option works fine.It impersonates all the user calls. But I wan to use serviceaccount and useraccount at times. Coule you please look in the below code and let me know why it is failing?
    teh problem is described below.
    I have an IIS app pool account to interact with the sharepoint server. but there are cases when I need to use the logged in users credentials instead of appPool account when doing some operations like uploading a document. So I decided to impersonate. I
    added the below code in the web.config file so that all  server calls are impersonated.
    <serviceBehaviors>
    <behavior name="ImpersonatedBehavior">
    <serviceMetadata httpGetEnabled="true" />
    <serviceDebug includeExceptionDetailInFaults="false" />
    <serviceAuthorization impersonateCallerForAllOperations="true"
    </behavior >
    </serviceBehaviors>
    and then i have a file uplaod method as given below
    public string UploadFile(objDocument)
    using (ClientContext clientContext = new ClientContext(objDocument.workspaceUrl))
    Site site = clientContext.Site;
    clientContext.Load(site, s => s.Url); //need url for some reasons
    clientContext.ExecuteQuery(); //Exception :UnAuthorized
    File.SaveBinaryDirect(clientContext, urlpart+ "/" + FileName, stream, true);
    clientContext.ExecuteQuery();
    the very first call to ExecuteQuery was throwing exception "UnAuthorized".actually  the user has full control on the particluar workspace.then I add the below piece of code ( just before the clientContext object initilaiztion )so that clientcontext
    object is created using the serviceAccount(appPool Account). then it was working fine. but failing at File.SaveBinaryDirect() method call.
    WindowsImpersonationContext ctx = null;
    if (!WindowsIdentity.GetCurrent().IsSystem)
          ctx = WindowsIdentity.Impersonate(System.IntPtr.Zero);
    using (ClientContext clientContext = new ClientContext(objDocument.workspaceUrl))
      Site site = clientContext.Site;
      clientContext.Load(site, s => s.Url); //need url for some reasons
      clientContext.ExecuteQuery();  //Working Fine now.
    if (ctx != null)
    ctx.Undo();// co'z while uploading the file we dont need appPool account.but need users account.
    File.SaveBinaryDirect(clientContext, urlpart+ "/" + FileName,  stream, true);
    clientContext.ExecuteQuery();//Exception
    finally
                        if (ctx != null)
                            ctx.Undo();
    Now it is throwing exception at the File.SaveBinaryDirect() saying "401:Unauthorized".

  • Windows Service Monitoring

    Hello All, 
    I have implemented a Windows Service Monitoring to look after some custom windows services on a Windows Server with a 3rd party piece of software installed. The monitor has been working as expected and has kept an eye on the services and alerted when they
    have stopped.
    However, the support team are now reporting that they are alerted when the service stops and starts. And they receive the same alert regardless, stating that the service has been stopped. 
    Is there something I am missing from my configuration? How can I amend it so that the support team are only alerted when the service is stopped? And why would it alert when its started?
    Hope someone can help
    James

    This actually sounds like a notification issue.  Do they have notifications set up to send them emails when an alert goes from one state to the next?  What I mean by that is, New Alert, Closed Alert.  When setting up notifications, it's a
    common mistake to not include the alert criteria, which will cause behavior like this, ops teams getting several emails when the state of the alert is changed by the system or operator.  If you look at the alert details in the email, you may notice, a
    slight difference in the resolution state field, if that is displayed.
    If this is the issue, find the notification subscription and have it changed so that they only receive alerts with a resolution state of NEW.
    Regards, Blake Email: mengotto<at>hotmail.com Blog: http://discussitnow.wordpress.com/ If my response was helpful, please mark it as so, if it answered your question, then please also mark it accordingly. Thank you.

Maybe you are looking for

  • 2010 Mac Mini sound skipping

    Have a 2010 Mac Mini Server 4 GB RAM 2.66 Ghz running OSX Server 10.6.7. Ever since I purchased in February 2011, the machine has had skipping audio regardless of the source - You Tube or other internet streaming, local quick time movie playback, i-t

  • If i add two officially released and named albums with the same name, they keep compiling as one album. How to separate the tracks by artist??

    I need immediate help. So here's the situation: Okay so I added an RHCP (Red Hot Chili Peppers) album that is named Greatest Hits on my iPod and I also added an The Offspring album also named Greatest Hits to my iPod and both tracks of the albums gro

  • Screwy display with a User setting

    The display setting are wonky for one of my User login profiles. The display is high contrast, grainy, and type is blurry. When I log in as a different user, all is fixed and display is perfect. If I create a new user, display is still good, however,

  • Will BB fix most of these "issues"

    Hi all, I am new to BB with the Z10. I really want to keep this device.  I really like the simplicity of the phone as a productivity device. I have had Android and they work well, but I don't really care for all the other "**bleep**" they seem to hav

  • Uploading TIFF image

    Hi, While uploading a tiff image using the program RSTXLDMC, I am getting the error "TIFF format error: No baseline TIFF 6.0 file". Could anyone help me in solving this? I also tried using SE78. Iam getting a error there also. Regards, Jeyananth