The request failed with HTTP status 401: Unauthorized. SSRS - reporting-services

I have a class in a MVC web project that processes SSRS.
When I run the app in the IIS machine I access the reports OK.
When run from another machine on the network gives me "The request failed with HTTP status 401: Unauthorized."
The Report Server has own unique credentiais. Does not accept the logon credentials on the network
Annex a part of the class
reportViewer.ProcessingMode = ProcessingMode.Remote;
reportViewer.ServerReport.ReportServerUrl = new Uri(System.Configuration.ConfigurationManager.AppSettings["RSUrl"]);
reportViewer.PromptAreaCollapsed = true;
reportViewer.ShowParameterPrompts = false;
reportViewer.SizeToReportContent = true;
reportViewer.InteractivityPostBackMode = InteractivityPostBackMode.AlwaysAsynchronous;
reportViewer.AsyncRendering = false;
if (reportType == "GRP")
{
reportViewer.ShowToolBar = false;
reportViewer.ShowPageNavigationControls = false;
}
else //if (reportType == "RPT")
{
reportViewer.ShowToolBar = true;
reportViewer.ShowPageNavigationControls = true;
}
strReportName = _reqObjNm;
strReportPath = System.Configuration.ConfigurationManager.AppSettings["RSPath"];
reportViewer.ServerReport.ReportPath = strReportPath + strReportName;
string RSUsername = System.Configuration.ConfigurationManager.AppSettings["RSUserName"];
string RSPwd = System.Configuration.ConfigurationManager.AppSettings["RSPwd"];
string RSDomain = System.Configuration.ConfigurationManager.AppSettings["RSDomainFull"];
//App_Start.ReportViewerCredentials rvCreds = new App_Start.ReportViewerCredentials(RSUsername, RSPwd, RSDomain);
//reportViewer.ServerReport.ReportServerCredentials = rvCreds;
reportViewer.Visible = true;
if (reportViewer.ServerReport.GetParameters().Count > 0) // HERE breaks :(

If I understand your question correctly I think you need to add a "ReportUser" to the remote SSRS server as a local user and in SSRS manager grant the local "ReportUser" user account proper access.

Related

StmpClient use works for remote users via VPN but not for users in office, on the network

I've implemented the .NET SmtpClient to send emails programmatically. Multiple users of the application and at various stages, an email is automatically sent. For users that are running the application from home, over VPN, the email almost always works. For users at the office, the email fails, "Failure sending mail" is exception message with no inner exception. The email server is MS Exchange, for large financial institution. Not using SSL, using port 25.
SmtpClient mailClient = new SmtpClient (getSmtpServer(), getSmtpPort());
mailClient.Timeout = 20000;
mailClient.UseDefaultCredentials = true;
MailAddress from = new MailAddress ( getSmtpFromAcct(),
"My Application",
System.Text.Encoding.UTF8);
MailAddress to = new MailAddress ( toEmail );
MailMessage message = new MailMessage(from, to);
for( int i = 1; i < toUsers.Count; i++)
{
BeanUser beanUser = toUsers[ i ];
message.To.Add( beanUser.getEmail() );
}
message.Subject = subject;
message.Body = messageBody;
mailClient.Send(message);

How to update Google Group Settings with Google Apps Script

I have a Google Apps Script which has all the permissions it needs, with the Group Settings API on and working, but does not change certain things. There are no errors given, but the only thing that changes is the name, and the rest does nothing. This is the script:
function modgroup() {
var groupKey = 'finaltest#school.edu.mx';
var resource = {
name: "finalfour",
whoCanContactOwner: "ALL_MEMBERS_CAN_CONTACT",
whoCanJoin: "INVITED_CAN_JOIN",
whoCanViewMembership: "ALL_MEMBERS_CAN_VIEW",
whoCanViewGroup: "ALL_MEMBERS_CAN_VIEW",
whoCanInvite: "ALL_MANAGERS_CAN_INVITE",
whoCanAdd: "ALL_MANAGERS_CAN_ADD",
allowExternalMembers: false,
whoCanPostMessage: "ALL_MEMBERS_CAN_POST",
allowWebPosting: false
}
AdminDirectory.Groups.update(resource, groupKey);
}
Ok, after a bit of investigation and experimentation, I found that there was another API and another format that had to be used so that it will work. You need to activate the Groups Settings API (not the Admin Directory API) and you can see the documentation here.
The format is the following:
function editGroup(){
var groupId = 'finaltest#school.edu.mx';
var group = AdminGroupsSettings.newGroups();
group.name = 'NAME';
group.description = 'DESCRIPTION';
group.whoCanAdd = 'NONE_CAN_ADD';
group.whoCanJoin = 'INVITED_CAN_JOIN';
group.whoCanViewMembership = 'ALL_MEMBERS_CAN_VIEW';
group.whoCanViewGroup = 'ALL_MEMBERS_CAN_VIEW';
group.whoCanInvite = 'ALL_MANAGERS_CAN_INVITE';
group.allowExternalMembers = false;
group.whoCanPostMessage = 'ALL_MEMBERS_CAN_POST';
group.allowWebPosting = true;
group.showInGroupDirectory = false;
group.allowGoogleCommunication = false;
group.membersCanPostAsTheGroup = false;
group.includeInGlobalAddressList = false;
group.whoCanLeaveGroup = 'NONE_CAN_LEAVE';
AdminGroupsSettings.Groups.patch(group, groupId);
}

EWS - Attachment Not Sent With Invitation

I am facing an issue with sending attachments with invitation using EWS Managed API. Appointments attendees are not receiving any attachments added to the appointment but
attachment do appears in the calendar of the person that created the appointment.
Here is my code snippet:
try
{
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP1, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
service.Credentials = new WebCredentials("calendar_user", "password1", "acme");
service.Url = new Uri("https://acme.com/EWS/Exchange.asmx");
Appointment appointment = new Appointment(service);
service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "tin.tin#acme.com");
String UID = "D09F3FF6-1461-414C-89E8-C05BC3B66A4A";
appointment.ICalUid = UID;
appointment.Subject = "Test Subject";
appointment.Body = "Test Content.";
appointment.Start = new DateTime(2012, 07, 11, 17, 00, 0);
appointment.End = appointment.Start.AddMinutes(30);
FileAttachment attachment = appointment.Attachments.AddFileAttachment(#"C:\Users\tintin\Documents\Test.xlsx");
attachment.IsInline = false;
appointment.RequiredAttendees.Add("tin.tin#acme.com");
appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);
}
catch (Exception ex)
{
}
Look like EWS has horrible limitation with attachment handling. I found a workaround to resolve this issue which requires updating appointment object twice.
appointment.ICalUid = UID;
appointment.Subject = "Test Subject";
appointment.Body = "Test Content.";
appointment.Start = new DateTime(2012, 07, 11, 17, 00, 0);
appointment.End = appointment.Start.AddMinutes(30);
FileAttachment attachment = appointment.Attachments.AddFileAttachment(#"C:\Users\tintin\Documents\Test.xlsx");
attachment.IsInline = false;
appointment.Save(folderCalendar, SendInvitationsMode.SendToNone);
appointment.RequiredAttendees.Add("tin.tin#acme.com");
appointment.Update(ConflictResolutionMode.AutoResolve, SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);
Looks like this issue is specific to Exchange Server 2010 Service Pack 1. I got similar issue and when I changed the version to SP2 issue got resolved. Below code solved the problem
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
A second update did the trick, but it will cause a cancelled meeting at the bottom. Can't use it in product.
It doesn't work to change the version to SP2.
Still find a better solution.
Yes, EWS has some issue, while updating the meeting with new attachments it is not getting updated for the first time. Needed 2 instances to update it.
Microsoft.Exchange.WebServices.Data.Appointment meet1 = await
Microsoft.Exchange.WebServices.Data.Appointment.Bind(service, strMessageID);
meet1.Attachments.Clear();
foreach (FileUpload Item in
objCreateEvent.strAttachmentUploadPath)
{
meet1.Attachments.AddFileAttachment(Item.fileName,
Item.filePath);
}
meet1.RequiredAttendees.Clear();
foreach (string ToItem in objToIds)
{
meet1.RequiredAttendees.Add(ToItem);
}
await
meet1.Update(ConflictResolutionMode.AlwaysOverwrite,
SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);
Microsoft.Exchange.WebServices.Data.Appointment
meeting2 = await Microsoft.Exchange.WebServices.Data.Appointment.Bind(service,
strMessageID);
meeting2.Attachments.Clear();
foreach (FileUpload Item in
objCreateEvent.strAttachmentUploadPath)
{
meeting2.Attachments.AddFileAttachment(Item.fileName, Item.filePath);
}
meeting2.RequiredAttendees.Clear();
foreach (string ToItem in objToIds)
{
meeting2.RequiredAttendees.Add(ToItem);
}
await
meeting2.Update(ConflictResolutionMode.AlwaysOverwrite,
SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy);

Entity Framework SaveChanges function won't commit my changes

I have an initial selection which I place into list. I use the list to loop through each record and where it meets certain criteria I run trough a series of inserts, deletes and updates. Finally call the SaveChanges() method to commit changes.
The code runs through without raising an exception but no changes reflect in the database. I have been searching the web with no luck.
I'm using VS2008 with SQL2008 backend.
Please help?
using (SMSEntities db = new SMSEntities())
{
try
{
//Get SMS's to send from Inbox
List<Inbox> tmpInbox = (from c in db.Inboxes where c.Status != "NEW" && c.Status != "SUCCESS" select c).ToList();// new { Inbox.InboxID, Inbox.StatusTrackingID, Inbox.Status, Inbox.NoOfAttempts, Inbox.CellNo, Inbox.SourceCellNo, Inbox.Header, Inbox.Message, Inbox.MessageDate, Inbox.AccountID, Inbox.LastAttemptDate }).ToList();
foreach (Inbox tmpInboxIndex in tmpInbox)
{
bool success = false;
//Check status here
string SentStatus = CheckSMSSentToProvider(tmpInboxIndex.StatusTrackingID);
// Define a transaction scope for the operations.
using (TransactionScope transaction = new TransactionScope())
{
try
{
if ((SentStatus == "DELIVERED") || (SentStatus == "NOTFOUND") || (SentStatus == "DELETED") || (SentStatus == "REJECTED") || (SentStatus == "UNDELIVERED"))
{
//Insert the Log row
Log newLog = new Log();
newLog.InboxID = tmpInboxIndex.InboxID;
newLog.CellNo = tmpInboxIndex.CellNo;
newLog.SourceCellNo = tmpInboxIndex.SourceCellNo;
newLog.Message = tmpInboxIndex.Message;
newLog.Header = tmpInboxIndex.Header;
newLog.MessageDate = tmpInboxIndex.MessageDate;
newLog.AccountID = tmpInboxIndex.AccountID;
newLog.ProcessedDate = DateTime.Now;
newLog.Status = tmpInboxIndex.Status;
newLog.StatusTrackingID = tmpInboxIndex.StatusTrackingID;
newLog.NoOfAttempts = tmpInboxIndex.NoOfAttempts;
newLog.LastAttemptDate = tmpInboxIndex.LastAttemptDate;
db.Logs.AddObject(newLog);
//Delete the Inbox row
if (tmpInbox != null)
{
var deleteInbox = (from c in db.Inboxes where c.InboxID == tmpInboxIndex.InboxID select c).FirstOrDefault();
if (deleteInbox != null)
{
db.DeleteObject(deleteInbox);
//db.SaveChanges(SaveOptions.DetectChangesBeforeSave);
}
}
}
else
{
//Update inbox status
var tmpUpdateInbox = (from c in db.Inboxes where c.InboxID == tmpInboxIndex.InboxID select c).FirstOrDefault();
tmpUpdateInbox.Status = SentStatus;
tmpUpdateInbox.NoOfAttempts = tmpInboxIndex.NoOfAttempts + 1;
tmpUpdateInbox.LastAttemptDate = DateTime.Now;
//db.SaveChanges(SaveOptions.DetectChangesBeforeSave);
}
// Mark the transaction as complete.
transaction.Complete();
success = true;
//break;
}
catch (Exception ex)
{
// Handle errors and deadlocks here and retry if needed.
// Allow an UpdateException to pass through and
// retry, otherwise stop the execution.
if (ex.GetType() != typeof(UpdateException))
{
Console.WriteLine("An error occured. "
+ "The operation cannot be retried."
+ ex.Message);
break;
}
// If we get to this point, the operation will be retried.
}
}
if (success)
{
// Reset the context since the operation succeeded.
//db.AcceptAllChanges();
db.SaveChanges();
}
}
// Dispose the object context.
db.Dispose();
}
catch (Exception exp)
{
throw new Exception("ERROR - " + exp.Message.ToString(), exp);
}
}
return true;
Regards,
GPR.
Are you using a local database file? You may be looking for changes in the wrong place. By default, when the program starts, VS copies the database file into the debug or release folder. Then the program runs and changes are made, and saved, to the file in the debug or release folder. The program ends, and when you look at the database in your source folder it looks the same. You can change the connection string in the app.config to use an absolute path to avoid this.
See http://blogs.msdn.com/b/smartclientdata/archive/2005/08/26/456886.aspx for more info
The TransactionScope is useless if you do not put the call to SaveChanges into it.
Either move the call to SaveChanges into it or remove the TransactionScope completely.

subscription in reporting services

I want to subscribe report on specific schedule in reporting services 2008. i.e report will dilever to user automatically on schedule. I am using visual studio 2008. I have done the configuration setting (rsreportserver.config, app.config after adding refrences of asmx files) by refrence msdn. The code is running fine (no exception occur) and I also get subscription id through calling create subscription indicate all going fine. But after running the code no entry made in Subscription table of ReportServer database. And also not get any mail. While through report server web tool, I can get email and also entery made in database but not from coe. Please someone help me. What I am missing. Plz help
Code is given follow: (Keep in mind, I am using VS2008)
void SendReportEmail()
{
RSServiceReference.ReportingService2005SoapClient rs=new RSServiceReference.ReportingService2005SoapClient();
rs.ClientCredentials.Windows.AllowedImpersonationLevel = new System.Security.Principal.TokenImpersonationLevel();
string batchID = string.Empty;
RSServiceReference.ServerInfoHeader infoHeader = rs.CreateBatch(out batchID);
BatchHeader bh = new BatchHeader()
{
BatchID = batchID,
AnyAttr = infoHeader.AnyAttr
};
string report = "/PCMSR6Reports/PaymentRequestStatusMIS";
string desc = "Send email from code to Hisham#comsoft.com";
string eventType = "TimedSubscription";
string scheduleXml="<ScheduleDefinition xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><StartDateTime xmlns=\"http://schemas.microsoft.com/sqlserver/2006/03/15/reporting/reportingservices\">2010-03-06T15:15:00.000+05:00</StartDateTime></ScheduleDefinition>";
RSServiceReference.ParameterValue[] extensionParams = new RSServiceReference.ParameterValue[7];
extensionParams[0] = new RSServiceReference.ParameterValue();
extensionParams[0].Name = "TO";
extensionParams[0].Value = "Hisham#comsoft.com";
extensionParams[1] = new RSServiceReference.ParameterValue();
extensionParams[1].Name = "IncludeReport";
extensionParams[1].Value = "True";
extensionParams[2] = new RSServiceReference.ParameterValue();
extensionParams[2].Name = "RenderFormat";
extensionParams[2].Value = "MHTML";
extensionParams[3] = new RSServiceReference.ParameterValue();
extensionParams[3].Name = "Subject";
extensionParams[3].Value = "#ReportName was executed at #ExecutionTime";
extensionParams[4] = new RSServiceReference.ParameterValue();
extensionParams[4].Name = "Comment";
extensionParams[4].Value = "Here is your test report for testing purpose";
extensionParams[5] = new RSServiceReference.ParameterValue();
extensionParams[5].Name = "IncludeLink";
extensionParams[5].Value = "True";
extensionParams[6] = new RSServiceReference.ParameterValue();
extensionParams[6].Name = "Priority";
extensionParams[6].Value = "NORMAL";
RSServiceReference.ParameterValue[] parameters = new RSServiceReference.ParameterValue[10];
parameters[0] = new RSServiceReference.ParameterValue();
parameters[0].Name = "BranchId";
parameters[0].Value = "1";
parameters[1] = new RSServiceReference.ParameterValue();
parameters[1].Name = "UserName";
parameters[1].Value = "admin";
parameters[2] = new RSServiceReference.ParameterValue();
parameters[2].Name = "SupplierId";
parameters[2].Value = "0";
string matchData = scheduleXml;
RSServiceReference.ExtensionSettings extSettings = new RSServiceReference.ExtensionSettings();
extSettings.ParameterValues = extensionParams;
extSettings.Extension = "Report Server Email";
try
{
string sub="";
RSServiceReference.ServerInfoHeader SubID = rs.CreateSubscription(bh, report, extSettings, desc, eventType, matchData, parameters, out sub);
rs.FireEvent(bh, "TimedSubscription", sub);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
Detail response will be highly appricated.
Try adding # at the beginning of your xml string #"