|
candogu wrote: Hi thank you for quick answer but I don't want "Administrator group" to stop or restart the service. Because like I said we add our users to Administrator group.
Can't be done. The person owning and driving the car decides, not the manufacturer. If it's their computer, they are in control of their system.
If they shouldn't be, then they shouldn't be administrators. You can't have both.
Bastard Programmer from Hell
|
|
|
|
|
To extend Eddy's answer, why are you making users Administrators? That's a really dangerous practice, and should be discouraged.
|
|
|
|
|
Because they would add or remove programs when I add them to Users group, they cannot.
|
|
|
|
|
Is this an organisational thing? Most organisations that I know prevent users from adding/removing programs and require central management of applications; which means that the user cannot add "dodgy" applications themselves. If you allow people to pick their own applications, you are opening up a particularly nasty can of worms there.
|
|
|
|
|
Like that, we want users to add or remove programs as they need (want), but we absolutely don't want our application to be stopped disabled, removed or killed from system. Thanks.
|
|
|
|
|
..walks over to the computer and pulls the electrical cord, just because it's possible.
"Now what"?
Bastard Programmer from Hell
|
|
|
|
|
The UPS just kicked in. And in a few hours the Diesel group will start roaring.
Luc Pattyn [My Articles] Nil Volentibus Arduum
Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
|
|
|
|
|
|
Then the same security adice applies. The only problem with doing this is that REAL Admins will no longer be able to control the service either. Only the System would be able to do it and your not going to convince the system to do so.
Talk about the Wild West. Your security environment is so screwed up. You say you've given users Administrator rights just to install software. What you've really done is given users the keys to do ANYTHING AND EVERYTHING, not just install software.
What you've done, out of convenience to the users, has created a giant headache for you. The only REAL way out of this problem is to revoke those admin privs and knock everyone back to Users, except, of course, the REAL admins. Then your group would have to take over clearing software for production use and installing it.
The service does not dictate who is going to stop it and who isn't. That's determined by the ACL (Access Control List, or Security) on the service.
|
|
|
|
|
|
I'd just like to reinforce the answers that say your security policy is broken here. Either you trust your staff, in which case you don't need a monitoring service that they can't kill, or you don't, in which case they shouldn't be admins. You are searching for a technical solution to a HR problem.
The simplest approach here is to make disabling the service a disciplinary offence.
Edit: also, this really isn't a C# question.
|
|
|
|
|
candogu wrote: I need to make a windows service that will return Access is denied when a user
in admin group
To answer another way, Don't, just don't, oh for the love of humanity don't.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Okay I found the solution. I give blue screen error when a user even administrator tries to kill my process and service and it cannot be stopped for now according to my tests. However, system doesn't normally shutdown by the service. Windows gives blue screen error from service side when I try to shut down or logoff. From windows process I detect SessionEnding event and I close my application under my control but from service I cannot detect SessionEnding event. What can I do here? What should I use instead SystemEvents? From CSHARP
|
|
|
|
|
The problem with your solution is that you will blue screen whenever anything causes the service to stop, including the service erroring out. As you have been told, the only way to accomplish what you want is to use the Access Control List (ACL) to say who can do what with the service. But seriously, the advise we gave you is good advice - we aren't ripping into your question, we are telling you that from real life experience, relying on users having admin privilege is dangerous.
|
|
|
|
|
I know that but I have nothing to do with that because I am not the manager okay. Finally I solved my question myself. When computer is shutting down or session is ending, I detect it and I disable critical system process. And windows can normally shutsdown and logs off. How can I set ACL? When I set ACL, can administrators kill my service? Thanks.
|
|
|
|
|
how to prepare synopsis for Resource Sharing and Conflict Management System
|
|
|
|
|
Is this a C# question? If so please give some more detail of the problem you are trying to solve.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
How to prepare?
Well, that starts by getting a definition for those terms. Then you'd decide the scope of your synopsis. How far are you at this point?
Bastard Programmer from Hell
|
|
|
|
|
I am working on some code to replace all of the LF end of line chars with CRLF in a text file. I wanted to account for the scenario of if the file does contain CRLF already and am not sure how. My current code will replace CRLF with CRCRLF which is not good. Does anyone have any ideas? Thanks in advance for your assistance!
string data = null;
using (StreamReader srFileName = new StreamReader(FileName))
{
data = srFileName.ReadToEnd();
data = data.Replace("\n","\r\n");
}
using (StreamWriter swFileName = new StreamWriter(FileName))
{
swFileName.Write(data);
}
|
|
|
|
|
One easy method would be:
data = data.Replace("\r\n","\n");
data = data.Replace("\n","\r\n");
But thats doing two replaces which might be a performance issue.
Another method I think should work is to use File.ReadAllLines() followed by File.WriteAllLines().
Yet another method would be to use regex to match \n's that are NOT preceeded by \r's.
|
|
|
|
|
Hi every body
I want to send email in windows application.
when i trace code all is OK but no message is received in mailbox ,my code is below:
MailAddressCollection receivers = new MailAddressCollection();
MailMessage msg = new MailMessage();
msg.IsBodyHtml = true;
msg.From = new MailAddress("telavat@telavat.com", "Alireza Doroudian");
msg.To.Add("a.doroudian@gmail.com");
msg.Subject = "testofHtml";
msg.Body = "ww";
SmtpClient smpt = new SmtpClient();
smpt.Host = "localhost";
smpt.Port = 25;
smpt.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
smpt.Send(msg);
thanks for any guides
Regards
Ali
|
|
|
|
|
My first suggestion would be to remove your email addresses from your post . You are about to getting spammed into oblivion as spammers spider this forum for addresses.
|
|
|
|
|
smpt.Host = "localhost";
Do you have an SMTP server running on your localhost machine? The smtp host target needs to be a system that is running a mail server and can transport the mail message to its destination.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Use this class to send email on windows application:
public class Email
{
public void SendEmail(string userName, string password, string mailFrom, string mailTo, string subject, string message, bool isBodyHtml, string SmtpAdd, int port)
{
MailMessage msg = new MailMessage(mailFrom, mailTo, subject, message);
msg.IsBodyHtml = isBodyHtml;
System.Net.NetworkCredential cred = new
System.Net.NetworkCredential(userName, password);
System.Net.Mail.SmtpClient mailClient = new
System.Net.Mail.SmtpClient(SmtpAdd, port);
mailClient.EnableSsl = false;
mailClient.UseDefaultCredentials = false;
mailClient.Credentials = cred;
mailClient.Send(msg);
}
|
|
|
|
|
Hi All,
I have got stuck with some issue with export option of gridview to excel sheet. Kindly help me is sloving the porblem. Attachments are not coming in the excel exported.
Thank you.
Here is code
public void Export(string fileName, GridView gv)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
HttpContext.Current.Response.ContentType = "application/ms-excel";
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
Table table = new Table();
table.GridLines = GridLines.Both;
if (gv.HeaderRow != null)
{
PrepareControlForExport(gv.HeaderRow);
table.Rows.Add(getheader());
table.Rows.Add(gv.HeaderRow);
table.Rows[0].BackColor = System.Drawing.Color.FromArgb(37, 96, 133);
}
foreach (GridViewRow row in gv.Rows)
{
PrepareControlForExport(row);
table.Rows.Add(row);
}
if (gv.FooterRow != null)
{
PrepareControlForExport(gv.FooterRow);
table.Rows.Add(gv.FooterRow);
}
table.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
}
}
private static void PrepareControlForExport(Control control)
{
for (int i = 0; i < control.Controls.Count; i++)
{
Control current = control.Controls[i];
if (current is LinkButton)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as LinkButton).Text));
}
else if (current is ImageButton)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as ImageButton).AlternateText));
}
else if (current is HyperLink)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as HyperLink).Text));
}
else if (current is DropDownList)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as DropDownList).SelectedItem.Text));
}
else if (current is CheckBox)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as CheckBox).Checked ? "True" : "False"));
}
if (current.HasControls())
{
PrepareControlForExport(current);
}
}
}
|
|
|
|