UnAuthorized at service.FindFolders?

Hi :
I am using EWS for reading folders & mails in exchange server 2007, 2010.
I am getting error as 401 UnAuthorized on service.FindFolders.
I am providing url as https://server name/ews/exchange.asmx.
Please suggest.
Thanks,
Bhushan

That means there is an issue with the credentials your using either you have a typo or the User your trying to use doesn't have rights what does your code look like ?. You might want to test the credentials in something like the EWSEditor first to verify
http://ewseditor.codeplex.com/
Cheers
Glen

Similar Messages

  • If my iPad was opened by unauthorized apple service staff still I can used my warranty please help

    If my iPad was opened by unauthorized apple service staff still I can used my 1year warranty.please help

    Not usually, but ask at your nearest Apple Store or Apple Authorized Service Provider.

  • Return 504 Gateway TimeOut when access exchange service by domain/user and password

    hi,
    here is the scenario: a user of our app is in ntdev domain, and his exchange server located at apj.cloudmail.microsoft.com. our backend api is deployed at the Azure servers at US West.
    our api get 504 Gateway Timeout when calling the
    FindFolders API of exchangeService. does anyone know how to fix this issue? the following is the core code:
    var
    service = newExchangeService(ExchangeVersion.Exchange2010);
    service.Credentials =
    newNetworkCredential(username,
    password, domain);
    service.AutodiscoverUrl(emailAddress, RedirectionUrlValidationCallback);
    service.FindFolders(
    WellKnownFolderName.Root,
    newFolderView(1));

    That doesn't sound like its an EWS issue more an issue with the Network path your trying to traverse to the Exchange Server. My suggestion is that you test EWS using the EWSeditor
    https://ewseditor.codeplex.com/ (eg it sounds like you may have proxy server that expecting authentication etc.).
    Cheers
    Glen

  • Reporting Services Generates HUGE nasty looking error

    "System.Net.WebException: The request failed with HTTP status 401: Unauthorized. at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
    methodName, Object[] parameters) at ReportServices2008.ReportingService2005.CreateReport(String Report, String Parent, Boolean Overwrite, Byte[] Definition, Property[] Properties)...."
    So on the project I'm working there is a .net app that incorporates reporting services. I can run previously developed RS reports with no issue. If I try to develop a new RS report  or if I try to copy an existing report to a new location, it fails
    with the error above.
    I have already done several hours of research and it appears that an account associated with the Reporting Service service maybe the issue. My question is how do I verify what accounts are associated with which services within the Reporting Services?
    I have gone through the logs and it dosen't really point me in any specific direction. Same for the event log.
    Any help would be greatly appreciated.
    Thanks

    Hi BI-Bill,
    According to your description, you encountered the "The request failed with HTTP status 401: Unauthorized" when creating or copying a report to new report. Right?
    Generally, "The request failed with HTTP status 401: Unauthorized" occurs when
    The service account used to connect to the Report Server is not authorized.
    The Reporting Services is configured to use Kerberos, however, we didn't register Service Principal Name (SPN) for the account the Reporting Services is running under.
    So, to fix this issue, we can refer to the follow steps:
    Make sure the user is able to connect to the Report Server.
    If using Kerberos authentication, please make sure SPN is configured correctly. If using Kerberos authentication, please make sure SPN is configured correctly.
    For more information about Kerberos Authentication and how to register SPN for a report server in Reporting Services, please see the articles below:
    Configure Windows Authentication on the Report Server
    Register a Service Principal Name (SPN) for a Report Server
    Also since you want to create/copy a report to a new location, please make sure the service account has permission on the new location.
    Reference:
    The request failed
    with HTTP status 401: Unauthorized + Reporting Service
    Enabling Kerberos Authentication for Reporting Services
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Web service invocation problem on host hostname and port 8000 protocol : http logical port name : LP_WS_SMDAGENT_MONITORING

    hello colleagues,
    In the phase Connect Diagnostics dont show the Agent available in SLD, but when go to SLD i have the agents,
    Error,
    Connect Diagnostics Agent
    The table does not contain any data
    Agent availables in all SLD
    SOAP:1.007 SRT: Unupported xstream found: ("HTTP Code 401 : Unauthorized")
    Web service invocation problem on host hostname and port 8000 protocol : http logical port name : LP_WS_SMDAGENT_MONITORING
    Thanks

    OK, then pls follow below steps;
    - Go to step 'Create Users' in solman_setup System Preparation scenario and make sure the user SM_INTERN_WS has a green status. Use the 'Test Login' button to make sure the user is not locked and has correct credentials maintained in solman_setup
    - Immediately after checking the user status, navigate to Configure Connectivity->Enable Web Services and execute again the 'Create Logical Ports' automatic activity, in order to propagate the correct credentials to the Logical Port definitions.
    - If the above operation is not successful, repeat the two steps above, providing a different user Id in 'Create Users' step, eg SM_INTERN_W1. This will prevent situations where the user gets locked by Logical Ports using an obsolete password.
    Let me know the results.
    Regards,
    Vivek

  • Get agents gives "unauthorized error" in system preparation

    Dear All,
    In solman 7.1 in system prep, in connect diagnostics agents, when I do a "get agents" I get the following error?
    SOAP:1,007 SRT: Unsupported xstream found: ("HTTP Code 401 : Unauthorized")
    Web service invocation problem on host wsapsmdev01.idacorp.local and port 8001 protocol : http logical port name : LP_WS_SMDAGENT_MONITORING
    As it is getting SMD_ADMIN by default as it is a dialog user to connect to the Get Agents
    How to check if the solution manager is successfully connected with the SLD?
    Kindly help me regarding the same.
    Thanks & Regards
    Ajitabh

    Hi,
    in 7.1 while performing system prepartion itself you wil get one of the step 6 as "prepare landscape",6.1 as select sld and more  s t?
    Have you done that?
    you can check this http://wiki.sdn.sap.com/wiki/display/SMSETUP/Diagnostics+Agents#DiagnosticsAgents-SLDRegistrationAgentCandidatesManagement
    or more on this guide [Diagnostics agent 7.11|https://websmp205.sap-ag.de/~form/sapnet?_SHORTKEY=01100035870000703907&_OBJECT=011000358700000952852009E]
    Thanks,
    Jansi

  • Get agents gives "unauthorized error" in system prep

    In solman 7.1 in system prep, in connect diagnostics agents,  when I do a "get agents" I get the following error?
               SOAP:1,007 SRT: Unsupported xstream found: ("HTTP Code 401 : Unauthorized")
               Web service invocation problem on host wsapsmdev01.idacorp.local and port 8001 protocol : http logical port name :           LP_WS_SMDAGENT_MONITORING
    What user is being used to get the agents? SLDAPIUSER?
    Any help is greatly appreciated.
    Thanks,
    Daniel

    Hi
    I had similar problem in 7.1 sp4
    i deleted users SM_INTERN_WS and SM_EXTERN_WS and deleted all logical ports using systempreparation step 1& 5 and reran both the steps and it worked...
    immediately in the next step i could see diagnostic agent(SMD) connected.
    I hope this will help.
    Regards
    Ravi

  • 401 Error Proxy to SOAP

    Hi,
    We have sync interface for Proxy to SOAP. This interface works fine when run once.
    When we did volume testing, 10% of the messages ( randomly) failed  with 401 Unauthorized & 503 Service not aviabale.
    After researching we found a note 821026 which talks about the issue. We have done changes as per the note & inclease the connection Pool max to 100.
    Please advice, if there is anything we can do as it is still failing with 401 & 503 in PI.
    Regards

    Hi All,
    Thanks for reply. We have 3 PI Systems which calls the same Web service via SOAP (  Syn proxy-SOAP.
    First we observed this error in one of the system & now it comes in all. The error is
    com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.net.SocketTimeoutException: Read timed out
    The sequence of event is  Inbound message from ECC looks good, the Mapping is OK. I see in response  the red & the error is in Inbound of Response.
    Below is the log in MDT
    02.02.2012 18:12:03 Information The message was successfully received by the messaging system. Protocol: XI URL: http://xxxxpd312.r1-core.r1.xxx.net:50000/MessagingSystem/receive/AFW/XI Credential (User): PIISUSER
    02.02.2012 18:12:03 Information Using connection SOAP_http://sap.com/xi/XI/System. Trying to put the message into the request queue.
    02.02.2012 18:12:03 Information Message successfully put into the queue.
    02.02.2012 18:12:03 Information The message was successfully retrieved from the request queue.
    02.02.2012 18:12:03 Information The message status was set to DLNG.
    02.02.2012 18:12:03 Information Delivering to channel: CC_SOAP_Rcvr_PaymentVerification
    02.02.2012 18:12:03 Information MP: entering1
    02.02.2012 18:12:03 Information MP: processing local module localejbs/sap.com/com.sap.aii.af.soapadapter/XISOAPAdapterBean
    02.02.2012 18:12:03 Information SOAP: request message entering the adapter with user J2EE_GUEST
    02.02.2012 18:12:18 Error SOAP: call failed: java.net.SocketTimeoutException: Read timed out
    SOAP: error occured: com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.net.SocketTimeoutException: Read timed out
    02.02.2012 18:12:18 Error MP: exception caught with cause com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.net.SocketTimeoutException: Read timed out
    02.02.2012 18:12:18 Error Adapter Framework caught exception: java.net.SocketTimeoutException: Read timed out
    02.02.2012 18:12:18 Error Delivering the message to the application using connection SOAP_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.net.SocketTimeoutException: Read timed out. Setting message to status failed.
    SXMB Log from ECC . This is shown
    <!--  Inbound Message
      -->
    - <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="1">
      <SAP:Category>XIAdapterFramework</SAP:Category>
      <SAP:Code area="MESSAGE">GENERAL</SAP:Code>
      <SAP:P1 />
      <SAP:P2 />
      <SAP:P3 />
      <SAP:P4 />
      <SAP:AdditionalText>com.sap.engine.interfaces.messaging.api.exception.MessagingException: java.net.SocketTimeoutException: Read timed out</SAP:AdditionalText>
      <SAP:ApplicationFaultMessage namespace="" />
      <SAP:Stack />
      <SAP:Retry>M</SAP:Retry>
      </SAP:Error>
    I am not sure if this is issue in calling adapter engine( while sedning to web service) or When the Data is being send to Proxy this issue comes in.
    Ps: We have gone through many notes  & increase the connection pool & max wait time.
    Also we have increase the time out in SOAP adapter with no effect. BASIS is looking at SXMB_ADM Http paramterto increase but this was systems were working fine before that.
    Now even one message is not flowing.
    Thanks & please advice
    I

  • Using EWS to work with mail items from a range derived from Get-Date

    I am attempting to write a powershell script that uses EWS to move items from the prior month and create a folder named after that month to hold those items. 
    I am finding that the search filter only likes the format if you use .NET system.DateTime and not Get-Date.
    However it's strange, for testing I configured my variable to be the exact same format as the .NET format but it rejects it. 
    The error i receive is: 
    Exception calling "FindItems" with "2" argument(s): "The specified value is
    invalid for property."
    At line:1 char:1
    + $frFolderResult = $InboxFolder.FindItems($sfCollection,$view)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : ServiceResponseException
    For example, if i set $startdate and $enddate like this  $startdate=(([system.DateTime]::Today.AddDays(-60)))
    $startdate returns Monday, January 20, 2014 12:00:00 AM, and the search filter works fine.
    but if i set $startdate using this: $startdate = (Get-Date).AddMonths(-1).ToString("dddd, MMMM 01, 12:00:00 AM")
    It gets rejected event though the output is exactly the same.
    i.e. Friday, February 01, 2014 12:00:00 AM
    Any help would be appreciated. 
    Thank You. 
    #Set the mailbox that this script will run against
    $MailboxName = "[email protected]"
    # Set up the API dll path, AutoDiscover URL and AD account used to access the mailbox
    Import-Module "C:\Program Files\Microsoft\Exchange\Web Services\2.0\Microsoft.Exchange.WebServices.dll"
    $service = new-object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::"Exchange2010_SP2")
    $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
    $aceuser = [ADSI]$sidbind
    $service.AutodiscoverUrl($aceuser.mail.ToString())
    # Determine if the script is running in January in order to set the year used in the search filter
    if ((Get-Date).Month -eq 1) {
    $searchyear = (Get-Date).Year - 1
    Else{
    $searchyear = (Get-Date).Year
    # Set variables for the search filter to move items from the prior month to a folder
    $startdate = (Get-Date).AddMonths(-1).ToString("dddd, MMMM 01,")
    $startdatetime= "$startdate $searchyear 12:00:00 AM"
    $enddate = [System.DateTime]::DaysInMonth($(Get-date).Year, $(Get-date).Month -1)
    $priormonth = (Get-Date).AddMonths(-1).ToString("dddd, MMMM")
    $enddatetime = "$priormonth $enddate, $searchyear 11:59:59 PM"
    # Set up folder path locations for the search filter
    $folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)
    $MailboxRoot = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::MsgFolderRoot,$MailboxName)
    $InboxFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid)
    # Create the search filter
    $Sfgt = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsGreaterThan([Microsoft.Exchange.WebServices.Data.ItemSchema]::DateTimeReceived, $startdatetime)
    $Sflt = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsLessThan([Microsoft.Exchange.WebServices.Data.ItemSchema]::DateTimeReceived, $enddatetime)
    $sfCollection = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+SearchFilterCollection([Microsoft.Exchange.WebServices.Data.LogicalOperator]::And);
    $sfCollection.add($Sfgt)
    $sfCollection.add($Sflt)
    # Perform the search
    $view = new-object Microsoft.Exchange.WebServices.Data.ItemView(5000)
    $frFolderResult = $InboxFolder.FindItems($sfCollection,$view)
    # define the destination folder name, check if the destination folder exists
    $foldermonth = (Get-Date).AddMonths(-1).ToString("MM")
    $newFolderName = "$foldermonth$searchear"
    $fvFolderView = new-object Microsoft.Exchange.WebServices.Data.FolderView(10)
    $SfSearchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$newFolderName)
    $findFolderResults = $service.FindFolders($MailboxRoot,$SfSearchFilter,$fvFolderView)
    # Create the destination folder if necessary
    if ($findFolderResults.TotalCount -eq 0){
    $NewFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
    $NewFolder.DisplayName = $newFolderName
    $NewFolder.Save($MailboxRoot.Id.UniqueId)
    else{
    # Folder Already Exists - Do Nothing
    # Move the items in to the destination folder
    foreach ($miMailItems in $frFolderResult.Items){
    "Moving" + $miMailItems.Subject.ToString()
    [VOID]$miMailItems.Move($NewFolder.Id.UniqueId)

    The Managed API is expecting you to pass a Typed Value not a String so if you just use
    $startdatetime= [System.DateTime]::Parse("$startdate $searchyear 12:00:00 AM")
    That should work okay, the Managed API itself will then covert it to and from UTC and then submit the query eg
    <m:Restriction>
    <t:IsLessThan>
    <t:FieldURI FieldURI="item:DateTimeReceived" />
    <t:FieldURIOrConstant>
    <t:Constant Value="2014-02-24T03:26:34.889Z" />
    </t:FieldURIOrConstant>
    </t:IsLessThan>
    </m:Restriction>
    Which you can see yourself if you enable tracing eg
    $service.TraceEnabled = $true
    Cheers
    Glen

  • Variable scope issue - EWS

    Hi everyone,
    So I have a funny issue. From line 8 to line 37 I declare a set of variables, most of them with null values. Then I call a function: SetupEWSAndFolder (line 88) which sets a lot of these variables. Once the function exits, the variables are empty.
    How come ? I thought that variables defined at script level would be updated in child functions ? Is it because of the null value ? I have another script with the same kind of setup but the variables are not set to null and it works perfectly fine.
    And for the fun, i tested echoing the value at the end of the function of some variables and then outside and the one outside are not updated
    I also tested using: $global:mb for instance, I still have the initial value set in the script and not the one updated in the function
    Thanks for helping me clear up my misunderstanding of the issue
    Olivier
    # Using Export - Import would be easier but since we do not have the rights for it and it requires a specific role being assigned to us... here goes EWS!!!
    # Include the Exchange Web Service DLL
    Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\2.0\Microsoft.Exchange.WebServices.dll"
    # Import the logwrite ability
    . .\LogWrite.ps1
    ################################################### INITIAL VARIABLES SETUP ###################################################
    #Setting up the log file
    #$userLogon = $args[0]
    $userLogon = "olivraga"
    $Logfile = "$userLogon.log"
    #setting up the name of the top folder in which to transfer #Inbox#, #SentItems#, #DeletedItems#
    $folderName = "_AutoOffBoardingArchiveFolder"
    #get the current username
    $credUserName = Get-Content env:username
    #Setting the mailbox variable for the folder binds in EWS
    $mailbox = $null
    #Setting up the Exchange Web Services connection
    $ExchangeVersion = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2
    $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($ExchangeVersion)
    $mb = $null
    #Setting up the folder variables for general calls
    $rootFolderID = $null
    $topFolder = $null
    $iFolder = $null
    $dFolder = $null
    $sFolder = $null
    #Setting up the folder ID to the targetted mailbox
    #(otherwise we would target the mailbox of the current account which we do not want :))
    $inboxID = $null
    $deletedItemsID = $null
    $sentItemsID = $null
    #Setting up the #Inbox# , #SentItems# , #DeletedItems# folder variables
    $inbox = $null
    $deletedItems = $null
    $sentItems = $null
    ############################ Function that moves a folder to another folder, including sub folders ############################
    function MoveItems(){
    $source, $dest, $path = $args[0]
    LogWrite "Copying/Moving $path"
    #Pulls items by thousands at a time
    $ivItemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(1000)
    $fiItems = $null
    do{
    #Get the 1000 items present in the source folder
    $fiItems = $service.FindItems($source.Id,$ivItemView)
    foreach($Item in $fiItems.Items){
    # Copy the Message
    $Item.Copy($dest.Id) | out-null
    # If you want to switch to a move instead use:
    #$Item.Move($dest.Id)
    $ivItemView.Offset += $fiItems.Items.Count
    }while($fiItems.MoreAvailable -eq $true)
    #Do the subfolders now
    if ($source.ChildFolderCount -gt 0)
    # Deal with any subfolders first
    $folderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(1000)
    $foldersFound = $source.FindFolders($folderView)
    ForEach ($subFolder in $foldersFound.Folders)
    $subFolderToCreate = New-Object Microsoft.Exchange.WebServices.Data.Folder($service)
    $subFolderToCreate.DisplayName = $subFolder.DisplayName
    $subFolderToCreate.Save($dest.Id)
    MoveItems($subFolder, $subFolderToCreate, $path+"\"+$subFolder.DisplayName)
    ################################# Initial necessary setup like full access and EWS connection #################################
    function SetupEWSAndFolder(){
    $mailbox = (Get-ADUser $userLogon -Properties mail).mail
    # Giving the current account Full Access to the Mailbox
    Add-MailboxPermission -Identity $mailbox -User $credUserName -AccessRights FullAccess -InheritanceType All -Confirm:$false
    $service.Url = "https://webmail.brookfieldrenewable.com/EWS/Exchange.asmx"
    #$service.Credentials = new-object Microsoft.Exchange.WebServices.Data.WebCredentials($userLogon,$userPassword,"hydro")
    #$service.Credentials = $creds.GetNetworkCredential()
    $service.UseDefaultCredentials = $true
    $service.AutodiscoverUrl($mailbox)
    $mb = new-object Microsoft.Exchange.WebServices.Data.Mailbox("$mailbox")
    #Get the root folder ID of the targetted mailbox
    $rootFolderID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::msgfolderroot, $mb)
    #Create new top folder to contain the Inbox, DeletedItems and SentItems folder
    $topFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
    $topFolder.DisplayName = "$folderName"
    $topFolder.Save($rootFolderID)
    #Create the subfolders to the topFolder to copy or move the emails in #Inbox# , #SentItems# , #DeletedItems#
    $iFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
    $iFolder.DisplayName = "Inbox"
    $iFolder.Save($topFolder.Id)
    $sFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
    $sFolder.DisplayName = "SentItems"
    $sFolder.Save($topFolder.Id)
    $dFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
    $dFolder.DisplayName = "DeletedItems"
    $dFolder.Save($topFolder.Id)
    #Just to make sure that the folder is created and everything is updated nicely
    Start-Sleep 5
    $inboxID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$mb)
    $deletedItemsID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::DeletedItems,$mb)
    $sentItemsID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::SentItems,$mb)
    $inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, $inboxID )
    $deletedItems = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, $deletedItemsID)
    $sentItems = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, $sentItemsID)
    SetupEWSAndFolder #setup the EWS connections and the folders
    MoveItems ($inbox, $iFolder, "Inbox") #Copy (not move yet) Inbox to the archive folder
    MoveItems ($deletedItems, $dFolder, "DeletedItems") #Same but for deleted items
    MoveItems ($sentItems, $sFolder, "SentItems") #Same but for sent items
    ##################################################### Helper Code Blocks ######################################################
    <#
    #Block of code in case one does not know the ID of the folder, but since we just created the topFolder, we do not need to search for it :)
    #Bind to the MSGFolder Root
    $rootFolderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::MsgFolderRoot,"hydro\$userLogon")
    #Setup the retrieval of the folder ID just created
    $targetFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$rootFolderId)
    $searchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$folderName)
    $folderView = new-object Microsoft.Exchange.WebServices.Data.FolderView(1)
    $findFolderResults = $service.FindFolders($rootFolderId, $searchFilter, $folderView)
    #>

    When you read the about_scope you see:
            - An item you include in a scope is visible in the scope in which it
              was created and in any child scope, unless you explicitly make it
              private. You can place variables, aliases, functions, or Windows
              PowerShell drives in one or more scopes.
    To me, it means that if you define a variable at the script level, it is going to be availble at the function level. To me, the function scope level is a child of the script scope level.
    So I did a check and it works like you say. But it is annoying, look at the following script and result:
    #This is a scope test:
    $nbErrors = "script";
    Function DoErrorTest(){
    $nbErrors
    $nbErrors = "inside"
    $nbErrors
    DoErrorTest
    $nbErrors
    Result:
    script
    inside
    script
    Which logical and totally annoying at the same time. And, to me, it means that you can never assign a value in a child scope by using the name of the variable. But you can display the value of the parent scope variable as long as you don't give a value to
    a same name variable in a child scope....
    This is gonna be annoying...
    Thanks

  • EWS: Finding a default folder

    There is an  example here of finding the Conversation History folder on Exchange through EWS:
    http://msdn.microsoft.com/en-us/library/hh243707(v=office.14).aspx
    However,  the way that it is doing this is by searching for the display name....This won't work for other languages though.  For Exchange 2013, there is a Conversation History has a well known folder name so that can be used, but there is no such
    thing for Exchange 2010....
    Is there any other way to find the folder (in Exchange 2010) without resorting to name search?

    Depending on what version of the Lync Client created the Folder you should be able to search on the FolderClass eg
    SearchFilter sfFolder = new SearchFilter.IsEqualTo(FolderSchema.FolderClass,"IPF.Note.Microsoft.Conversation");
    FindFoldersResults ffResults = service.FindFolders(WellKnownFolderName.MsgFolderRoot, sfFolder, new FolderView(1));
    if (ffResults.Folders.Count == 1) {
    Console.WriteLine(ffResults.Folders[0].DisplayName);
    Cheers
    Glen

  • How to get shared calendars using EWS

    Hi,
    I want to monitor all calendars shared to a user via EWS. I know how to do this provided I know each of the user names. But I don't. So I need to get a list of all the users that have shared their calendar to one specific user. But how? I've searched around.
    Is it possible?
    If this is indeed not possible; is there a way to list all users? That way should be able to figure out which of them have shared their calendar with 'my' user, by trial and error if nothing else.
    Thank you and best regards,
    babu

    There is no direct way to do this however you can enumerate the Shared Calendar folders a user has added by enumerating the Nav links in the Common Views folder see
    http://msdn.microsoft.com/en-us/library/ee157359(v=exchg.80).aspx. You can then get the Mailbox this link refers to use the PidTagWlinkAddressBookEID and extracting the X500 address
    from that property. The you can just bind to each of the Folders using that information.
    eg
    static Dictionary<string, Folder> GetSharedCalendarFolders(ExchangeService service, String mbMailboxname)
    Dictionary<String, Folder> rtList = new System.Collections.Generic.Dictionary<string, Folder>();
    //GetSharedContacts
    FolderId rfRootFolderid = new FolderId(WellKnownFolderName.Root, mbMailboxname);
    FolderView fvFolderView = new FolderView(1000);
    SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "Common Views");
    FindFoldersResults ffoldres = service.FindFolders(rfRootFolderid, sfSearchFilter, fvFolderView);
    if (ffoldres.Folders.Count == 1)
    PropertySet psPropset = new PropertySet(BasePropertySet.FirstClassProperties);
    ExtendedPropertyDefinition PidTagWlinkAddressBookEID = new ExtendedPropertyDefinition(0x6854, MapiPropertyType.Binary);
    ExtendedPropertyDefinition PidTagWlinkFolderType = new ExtendedPropertyDefinition(0x684F, MapiPropertyType.Binary);
    ExtendedPropertyDefinition PidTagWlinkGroupName = new ExtendedPropertyDefinition(0x6851, MapiPropertyType.String);
    psPropset.Add(PidTagWlinkAddressBookEID);
    psPropset.Add(PidTagWlinkFolderType);
    ItemView iv = new ItemView(1000);
    iv.PropertySet = psPropset;
    iv.Traversal = ItemTraversal.Associated;
    SearchFilter cntSearch = new SearchFilter.IsEqualTo(PidTagWlinkGroupName, "Other Calendars");
    FindItemsResults<Item> fiResults = ffoldres.Folders[0].FindItems(cntSearch, iv);
    foreach (Item itItem in fiResults.Items)
    try
    object GroupName = null;
    object WlinkAddressBookEID = null;
    if (itItem.TryGetProperty(PidTagWlinkAddressBookEID, out WlinkAddressBookEID))
    byte[] ssStoreID = (byte[])WlinkAddressBookEID;
    int leLegDnStart = 0;
    String lnLegDN = "";
    for (int ssArraynum = (ssStoreID.Length - 2); ssArraynum != 0; ssArraynum--)
    if (ssStoreID[ssArraynum] == 0)
    leLegDnStart = ssArraynum;
    lnLegDN = System.Text.ASCIIEncoding.ASCII.GetString(ssStoreID, leLegDnStart + 1, (ssStoreID.Length - (leLegDnStart + 2)));
    ssArraynum = 1;
    NameResolutionCollection ncCol = service.ResolveName(lnLegDN, ResolveNameSearchLocation.DirectoryOnly, true);
    if (ncCol.Count > 0)
    FolderId SharedCalendarId = new FolderId(WellKnownFolderName.Calendar, ncCol[0].Mailbox.Address);
    Folder SharedCalendaFolder = Folder.Bind(service, SharedCalendarId);
    rtList.Add(ncCol[0].Mailbox.Address, SharedCalendaFolder);
    catch (Exception exception)
    Console.WriteLine(exception.Message);
    return rtList;
    Cheers
    Glen

  • Error when trying to search for folders within an Exchange server

    I am working on an existing application that searches folder within an exchange server in asp.net C#
    The code is very basic is like this 
    FolderView view = new FolderView(int.MaxValue);
                view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
                view.PropertySet.Add(FolderSchema.DisplayName);
                view.PropertySet.Add(FolderSchema.FolderClass);
                view.PropertySet.Add(FolderSchema.ParentFolderId);
                view.Traversal = FolderTraversal.Deep;
                FindFoldersResults findFolderResults = service.FindFolders(new FolderId(WellKnownFolderName.Root, mailbox), view);
    This code has been working on another Exchange server before.
    However when I try to change the exchange server I try to scan I get an error like this :
    Microsoft.Exchange.WebServices.Data.ServiceVersionException: Exchange Server doesn't support the requested version.
       at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ProcessWebException(WebException webException)
       at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request)
       at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request)
       at Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.InternalExecute()
       at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
       at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalFindFolders(IEnumerable`1 parentFolderIds, SearchFilter searchFilter, FolderView view, ServiceErrorHandling errorHandlingMode)
       at Microsoft.Exchange.WebServices.Data.ExchangeService.FindFolders(FolderId parentFolderId, FolderView view)
       at ExchangeSyncService.ExchangeToSqlService.SyncFolderForSubUser(ExchangeService service, Mailbox mailbox, Int32 nUserID)
    The Exchange server that succeeded and failed are both Exchange 2010.  I am searching are both Exchange 2010, and I checked the documentation that FindFolder is supported by all versions of Exchange 2010. 
    Is it really a version error or something else? Anyone have any insight on this?

    problem solved thanks Glen can I ask you a new question? I ran into another error after solving that problem I got an error message that says 
    Microsoft.Exchange.WebServices.Data.ServiceResponseException: The SMTP address has no mailbox associated with it.
       at Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary()
       at Microsoft.Exchange.WebServices.Data.ServiceResponse.ThrowIfNecessary()
       at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
       at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalFindFolders(IEnumerable`1 parentFolderIds, SearchFilter searchFilter, FolderView view, ServiceErrorHandling errorHandlingMode)
       at Microsoft.Exchange.WebServices.Data.ExchangeService.FindFolders(FolderId parentFolderId, FolderView view)
       at ExchangeSyncService.ExchangeToSqlService.SyncFolderForSubUser(ExchangeService service, Mailbox mb, Int32 nUserID) 
    The line of code that triggers this problem is 
    FolderView view = new FolderView(int.MaxValue);
                view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
                view.PropertySet.Add(FolderSchema.DisplayName);
                view.PropertySet.Add(FolderSchema.FolderClass);
                view.PropertySet.Add(FolderSchema.ParentFolderId);
     view.Traversal = FolderTraversal.Deep;
                FindFoldersResults findFolderResults = service.FindFolders(new FolderId(WellKnownFolderName.Root, mb), view);
    The error gets triggered on service.FindFolders. I am trying to grab all the folders from 1 user's account I am trying to access with a super admin account that has all access to all mailbox to all users on the server.
    Any idea what is going on there?  
    It worked on my previous server just not working on this new server here. 
    Thanks

  • HD space problems - scanning all mailboxes for large attachments

    Hello Exchange experts
    I have only 5 GB left on a database that has 150 MailBoxes.Until I connect some external storage to the server, i was wondering if there is some way on the server level to scan all the mailboxes for large attachments and delete them to save some space. I
    have exchange. 2010.

    First make sure database is consuming the space. This command will show you the database file size and path
    Get-MailboxDatabase -Status | select ServerName,Name,DatabaseSize,EdbFilePath
    Please take an exchange known backup if edb file size is not consuming the database drive space..
    http://technet.microsoft.com/en-us/library/dd876854(v=exchg.150).aspx. 
    I suggest you create a newdatabase and move all mailboxes to the newly created database.
    You could attach a HDD and create a mailbox database in that and move all mailboxes and delete the default database (after check this) and create new one in the
    place of default database move back all your mailboxes back from the newly connected HDD to this database. You can use this command to move mailboxes in bulk. Please check
    this
    Get-Mailbox –Database ‘Mailbox Database 001’ | New-MoveRequest –TargetDatabase ‘Mailbox Database 002’
    If you dont have enough space you could try defragmentation. But you make sure you have white space or no
    http://blogs.technet.com/b/rmilne/archive/2013/08/20/how-to-check-database-white-space-in-exchange.aspx
    Or this script remove all attachement that size >1000 KB
    first creat mailbox called it test , send many attachements to this this mailbox , in the code below change the line Get-Mailbox yourUserName to Get-Mailbox test
    Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll"
    $credentials = New-Object Microsoft.Exchange.WebServices.Data.WebCredentials(ADMINUSERNAME, PASSWORD)
    $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService
    $service.Credentials = $credentials
    $service.Url = "http://localhost/ews/exchange.asmx"
    $mailbox = Get-Mailbox yourUserName
    $folderFilter = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter
    $folderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(1000)
    $folderView.Traversal = [Microsoft.Exchange.WebServices.Data.FolderTraversal]::Deep
    $itemFilter = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.EmailMessageSchema]::HasAttachments, $true)
    $itemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(10000)
    write-host $mailbox.displayName
    $folderId = New-Object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::MsgFolderRoot, $mailbox.primarySmtpAddress.ToString())
    $folder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, $folderId)
    $folders = $service.FindFolders($folderId, $folderFilter, $folderView)
    foreach ($subFolder in $folders.Folders)
    write-host $subFolder.displayName
    $items = $subFolder.FindItems($itemFilter, $itemView)
    foreach ($item in $items.Items)
    write-host $item.subject
    $item.Load()
    foreach($attachment in $item.Attachments)
    if ($item.size > 1000){
    write-host $attachment.Name
    $item.Attachments.Remove($attachment)
    break
    $item.Update([Microsoft.Exchange.WebServices.Data.ConflictResolutionMode]::AutoResolve)
    Thanks, MAS
    Please mark as helpful if you find my comment helpful or as an answer if it does answer your question. That will encourage me - and others - to take time out to help you.

  • EWS Powershell: Set HomePageURL

    I'm so close its frustrating
    Building a powershell app to add a folder to a mailbox and set it with a homepage. I can create the folder and my code below sets the PR_FOLDER_WEBVIEWINFO property, but its not setting the correct value. If looking at MFCMapi the value I'm setting appears
    under "Value (alternative text)" rather than "Value".... 
    Here's the code, the $Encoded URL value is valid as if I input this directly into MFCMapi then the 'homepage' appears...  
    $EncodedURL = "020000000100000001000000000000000000000000000000000000000000000000000000000000002000000068007400740070003A002F002F00620069006E0067002E0063006F006D000000"
    $bqByteArray = [System.Text.Encoding]::ASCII.GetBytes($EncodedURL)
    $PR_FOLDER_WEBVIEWINFO = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(14047,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Binary)
    $NewFolder.SetExtendedProperty($PR_FOLDER_WEBVIEWINFO,$bqByteArray)
    $NewFolder.update()
    It's almost as if my $EncodedURL should be the byte array, but if I try to use
    $NewFolder.SetExtendedProperty($PR_FOLDER_WEBVIEWINFO,$EncodedURL) it just fails.... A little guidance please

    Hmm, Get errors with your code. Here's something I've put together. Very similar and wished I had seen yours a bit earlier. Would have made the task easier. Working on adding Get-Mailbox for all mailbox users.
    Open to suggestions.
    # Script is designed to create a new folder in Outlook and add a homepage URL
    # Tested using Exchange Server 2007SP1/2010SP1
    # Works for a single user only. Future designs to apply to Get-Mailbox users.
    # This file should be named with a *.ps1 extension to run. If need be, rename the file.
    # It is assumed this file and the associated dll are located in C:\Temp\, else
    # Update the $LogFile and $dllpath accordingly
    # User Settings
    $newFolderName = "Google"
    $CustomURL = "http://google.co.nz"
    $MailboxName = "[email protected]"
    $MailboxPwd = "pwd"
    $Domain = "" #Not Used yet
    $MbAdmin = "" #Not Used yet
    $MbAdminPwd = "" #Not Used yet
    $dllpath = "c:\temp\Microsoft.Exchange.WebServices.dll"
    [string]$LogFile = "C:\Temp\Log.txt"   # Path of the Log File
    Import-Module $dllpath
    [string]$info = "White"                # Color for informational messages
    [string]$warning = "Yellow"            # Color for warning messages
    [string]$error = "Red"                 # Color for error messages
    #Setup the service for the appropriate version of Exchange
    #$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP1)
    $Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP1)
    #$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2)
    #$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013)
    #Set login credentials
    #$Service.Credentials = New-Object System.Net.NetworkCredential($MailboxName,$MailboxPwd,$Domain)
    $Service.Credentials = New-Object Microsoft.Exchange.WebServices.Data.WebCredentials($MailboxName,$MailboxPwd)
    #Use hardcoded CAS Server URL or use Autodiscover
    #$service.Url= new-object Uri(http://CAS-Server/EWS/Exchange.asmx)
    $Service.AutodiscoverUrl($MailboxName,{$true})
    Write-host "EWS URL set to :" $Service.Url -foregroundcolor $info
    #Connect to users MsgFolderRoot and search for $newFolderName
    $RootFolderID = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::MsgFolderRoot,$MailboxName)
    $RootFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($Service,$RootFolderID)
    $FolderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(1) #Custom value. Enable the following line for +10
    #$FolderView.Traversal = [Microsoft.Exchange.WebServices.Data.FolderTraversal]::Deep
    $SfSearchFilter = new-object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$newFolderName)
    $findFolderResults = $service.FindFolders($RootFolderID,$SfSearchFilter,$FolderView)
    # If  $newFolderName found, say so.  
    if ($findFolderResults.TotalCount -ne 0){
     Write-host "Folder already exists for" $MailboxName -foregroundcolor  $info
     #Delete the folder ? ?
     #$newFolderName.delete([Microsoft.Exchange.WebServices.Data.DeleteMode]::SoftDelete) #DeletedItems
     #$newFolderName.delete([Microsoft.Exchange.WebServices.Data.DeleteMode]::HardDelete)
    # DON'T CHANGE BELOW THIS LINE
    # If $newFolderName not found create it and set homepage URL
    if ($findFolderResults.TotalCount -eq 0){
        Write-host $MailboxName ": Folder not found... Creating" -foregroundcolor  $warning >> $Logfile
     # Create the folder
     $NewFolder = new-object Microsoft.Exchange.WebServices.Data.Folder($service)
     $NewFolder.DisplayName = $newFolderName
     $NewFolder.Save($RootFolderID) 
     # Do the real work!
     # Generate HEX of URL
     $CharArray = $CustomURL.ToCharArray();
     $homepagebytes = $null
     Foreach ($Char in $CharArray) {$homepagebytes = $homepagebytes + [System.String]::Format("{0:X}", [System.Convert]::ToUInt32($Char))+"00"} 
     # String together the value for PR_FOLDER_WEBVIEWINFO
     $dwversion = "02"
     $dwType = "00000001"
     $dwFlags = "00000001"
     $dwUnused = "00000000000000000000000000000000000000000000000000000000"
     $cbDataSizePadding = "000000"
     $cbDataSize = (($homepagebytes.length / 2)+2).ToString($x)
     $cbDataSizePadding2 = "000000"
     $homepagebytesPadding = "0000"
     $HexURL = $dwversion + $dwType + $dwFlags + $dwUnused + $cbDataSizePadding + $cbDataSize + $cbDataSizePadding2 + $homepagebytes + $homepagebytesPadding
     # $HexURL = "020000000100000001000000000000000000000000000000000000000000000000000000000000002000000068007400740070003A002F002F00620069006E0067002E0063006F006D000000"  
     # Convert $HexURL to a Bytearray then Base64
     $bytes2 = @($HexURL -split '([a-f0-9]{2})' | foreach-object { if ($_) {[System.Convert]::ToByte($_,16)}})
     $Base64URL = [System.Convert]::ToBase64String($bytes2);
     # $Base64URL = "AgAAAAEAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAABoAHQAdABwADoALwAvAGIAaQBuAGcALgBjAG8AbQAAAA=="
     # read/write the URL into $PR_FOLDER_WEBVIEWINFO
     $bytes  = [System.Convert]::FromBase64String($Base64URL);
     $PR_FOLDER_WEBVIEWINFO = new-object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(14047,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Binary)
     $NewFolder.SetExtendedProperty($PR_FOLDER_WEBVIEWINFO,$bytes)
     #Save
     $NewFolder.update() 
     Write-host "Created for" $MailboxName -foregroundcolor  $info >> $Logfile
     Write-host "Finished" -foregroundcolor  $info
    # Credits to the following in no particular order:
    # Plus many many more. Thanks to you all.

Maybe you are looking for

  • Unable to start soa server with anonymous attempt to JNDI resource error

    I created a new outbound connection in my JMS Adapter deployment then I also created a new Foreign Server in my JMS Module that is deployed on my SOA server. Now when i try to restart my SOA server it is failing with the below exception. <Jul 1, 2011

  • Num_1099, individual_1099 columns in ap_suppliers

    We are on Oracle EBS 12.1.3. In supplier screen there are two places where user can enter tax number. One is by clicking on "Tax and Reporting" page and other location is "Tax and Financial Information" section under Organization page. Based on where

  • Anybody know of a discussion forum for Pro*C/C++?

    It would help immensely if someone could direct me to a group with a background in VC++ and Pro*C/C++. thanks for any consideration

  • Upload pages, no hyperlinks

    Hi, I have published a new site using iWeb using my own keywords w/ hyperlinks for menu. The hyperlinks are active in iWeb, but after publishing they are not. This has happened before to me. And yes I have cleared Safari's cache and history. What is

  • Sudden shutdown on battery requires SMC reset

    MacBook Pro 2.53 GHz Intel Core 2 Duo with 8 GB RAM. I mostly use this at home with a power cord. When I use it with the battery (Newer Tech with 131 charge cycles), the computer regularly shuts down after about 10 minutes of use without warning and