|
|
I've realized a custom UserNamePasswordValidator.
And I can't run my Service anymore.
if I remove the line :
tcpBinding.Security.Mode = SecurityMode.Message;
it works again, but without user validation....
here the source:
class Program
{
static void Main(string[] args)
{
ServiceHost myHost = new ServiceHost(typeof(classServerFunktionen));
NetTcpBinding tcpBinding = new NetTcpBinding();
tcpBinding.TransactionFlow = false;
tcpBinding.Security.Mode = SecurityMode.Message;
tcpBinding.Security.Message.ClientCredentialType = MessageCredentialType.UserName;
myHost.Credentials.UserNameAuthentication.UserNamePasswordValidationMode = System.ServiceModel.Security.UserNamePasswordValidationMode.Custom;
myHost.Credentials.UserNameAuthentication.CustomUserNamePasswordValidator = new CustomUserNameValidator();
myHost.AddServiceEndpoint(typeof(IServerFunktionen), tcpBinding, "net.tcp://localhost:8777/MyProdService");
//Server starten
myHost.Open();
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <enter> to terminate service.");
Console.ReadLine();
//Server schließen
myHost.Close();
}
}
public class CustomUserNameValidator : System.IdentityModel.Selectors.UserNamePasswordValidator
{
public override void Validate(string userName, string password)
{
if (null == userName || null == password)
{
throw new ArgumentNullException();
}
if (!(userName == "test1" && password == "1tset") && !(userName == "test2" && password == "2tset"))
{
throw new System.IdentityModel.Tokens.SecurityTokenException("Unknown Username or Incorrect Password");
}
}
}
//Implementierung des Interfaces mit den Serverfunktionen...
public class classServerFunktionen : IServerFunktionen
{
public String rights;
public String getMessage()
{
return "Hallo Session:" + OperationContext.Current.SessionId;
}
public String getMessage2()
{
return "Hallo2 Session:" + OperationContext.Current.SessionId;
}
}
and my interface:
[ServiceContract]
public interface IServerFunktionen
{
[OperationContract] //(ProtectionLevel = ProtectionLevel.EncryptAndSign)
String getMessage();
[OperationContract]
String getMessage2();
}
|
|
|
|
|
I get the error thet the ChannelDispatcher can't open his IChannelListener
|
|
|
|
|
I need code in C# to populate checkbox in gridview to delete records.
Please help.
Thank you
Saranya
|
|
|
|
|
SJSaranya wrote: populate checkbox in gridview to delete records.
Add a column to the datatable, which you want to assign as a data source to the gridview
like the following
dataTable1.Columns.Add("Name of My Column for the checkbox",typeof(bool),"0");
assign it as datasource.
kss
|
|
|
|
|
I have written code for windows application using C# where in on a button click, a new memo should be opened with email id, subject and body. I am using the code below
System.Diagnostics.Process.Start(String.Format("mailto:{0}?Subject={1}&Body={2}" , txtContEmail.Text.Trim(), strSubject, strBody));
The above code is working if the text specified in the variable strBody is short. But I have to create a body with the text given below
"Dear Customer,
Thank you for utilizing the the application.
The following license file(s) will expire in few days: .
The application will not operate with an expired license file. Please detach the license file attached to this e-mail and place it in the following location:C:\Program Files\SID\Bin. Replace the existing file with this new file.
Note: This file should only be saved in the before mentioned directory. Attempting to open the file may result in an “invalid file format” message.
Please also note that if you loose that license file and request to replace it, it would incur a USD 500 fee to cover the time and administration costs.
If our contact information has changed, please transfer this e-mail to the correct person and kindly provide us with his/her name, e-mail and phone number, thank you!
Don't hesitate to contact us if you have further questions.
Best regards,"
Because of this huge text nothing happens. But if I make the text shorter then the code is working. My default email account is Lotus Notes. Please help me.
Looney
|
|
|
|
|
Please - don't repost the same question so quickly. This is a volunteer based forum, where people get to your messages in their own time.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
How would I end another process from a C# app?
I do not want to call Process.Kill() as I have code that needs to run when the ApplicationExit event fires. I do not have a MainWindow so I can't call Process.CloseMainWindow(). Does anyone have another suggestion that I have missed?
|
|
|
|
|
Have you thought of putting in a kill method in the other process that you could call via remoting?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I hadn't thought of that. I was hoping for a nice simple way like the CloseMainWindow() function that I might have missed but that is certainly an option. Thanks.
|
|
|
|
|
You could add a main form, and make it invisible.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I gave that a go but if you set ShowInTaskBar to false the MainWindowHandle for the process is always 0 which prevents me from calling CloseMainWindow(). I have solved the problem with remoting now.
|
|
|
|
|
I'm glad that you solved it, and I'm glad that I managed to help even in a small way.
__DanC__ wrote: ShowInTaskBar to false the MainWindowHandle for the process is always 0
I know - it's a real bummer, which is why I didn't suggest this. Ho hum.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Ah, sh!t - sorry Pete, I voted you a 1 by accident (cack handed mouse skillz "r" us!)
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|
No bother - I'm not in this for the votes. But thanks anyway.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello to all.
My problem is, that I can't seem to understand how to pass the updating of my progressBar control to
the function it supposed to be updated by.
my function sits in a different class then my form and does some measurments that return values and
then it manipulates it for my bussiness needs.
the problem is that I want that function(called from a background worker thread in my form) that belongs to another class to be updating the progressBar on the form created in the main thread.
if I was inside the same thread background workerThread I don't have a problem using the reportProgress method, the problem is that start_ChannelA_Offsetting function belongs to another class
here is some relevant code, please help me...
private void frmPicoBackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
PICO.start_ChannelA_Offsetting(ref updateProgress);
frmPicoBackgroundWorker.ReportProgress(updateProgress);
}
private void frmPicoBackgroundWorker_ProgressChanged(object Sender, ProgressChangedEventArgs e)
{
progressBarSampling.Step = updateProgress;
progressBarSampling.PerformStep();
}
public void start_ChannelA_Offsetting(ref int updateProgress)
{
if (!Opened)
{
MessageBox.Show("device is not opened!!!");
return;
}
this.SetChannel(Channel_A, A_enabled, A_coupling, range);
this.RunStreaming((short)timeIntervalMs, this.maxSamples, windowed);
this.totNumOfSamples = (this.numValues / 2) * offsetChA.Length;
try
{
int i, j = 0, t;
for (j = 0, t = 0; j < totNumOfSamples - 1 || t == offsetChA.Length; t++)
{
Thread.Sleep((this.numValues / 2) * Convert.ToInt32(this.Intervalms));
values_collected = this.GetValues(bufferA, bufferB, bufferC, bufferD, out overflows, numValues);
if (values_collected < numValues / 2)
{
if (t >= 0)
t--;
continue;
}
updateProgress = Convert.ToInt32((j / totNumOfSamples) * 100);
for (i = 0; i < values_collected; i++, j++)
{
if (j == totNumOfSamples - 1)
{
break;
}
bufferA_mV[i] = this.adc_to_mv(bufferA[i], realRange);
}
if (i < values_collected - 1)
break;
this.offsetChA[t] = (sumBuffer(bufferA_mV) / (double)(i));
}
}
catch (Exception e)
{
MessageBox.Show("Finishing in an orederly fasion");
Console.WriteLine(e);
this.Stop();
}
if (Opened)
{
this.Stop();
MessageBox.Show("finished all requested sampling");
}
}
all help will be most appreciated.
|
|
|
|
|
Y isn't anyone answering me???????????????
|
|
|
|
|
Hi all
How can i display a msg to save before leaving the current page ONLY if the user has made changes in this page else i dont want to display the msg.
Is this possible? I have seen this senario working in CRM.
thanks
|
|
|
|
|
If you are talking about a web page, then this is a web development question, not a C# question, as you can't do it using C#.
Use the onunload event in Javascript to do something when you leave the page.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi.
I am doing an application in WPF where you can move around controls with your mouse. But what I want to do is to prevent the mouse cursor from leaving the area like in a MID forms application. I've tried to use set the mouse cursor on the MouseLeave and PreviewMouseMove event, but none of those solutions gives a good visual result. You can acctually see the cursor change position. I even made changed position on the Query event of my area (which is a canvas in this case).
Is there some magical solution to this? ..
Thanks in advance!
/Joakim.
|
|
|
|
|
hi,
i m new to directx programming... how can we create our own "direcshow filters"...? and register them in the registry...?
can anyone help please...?
thanks,
Kuldeep
|
|
|
|
|
http://amitranjan.wordpress.com/2006/05/31/enumerating-directshow-filters-on-wm5-deviceemulator/
Jintal Patel
|
|
|
|
|
|
I have file I want to transfer it from pc to another via modem the problem is I want to make the procedure on one button click. one in the sender side to send the file and another on the receiver side to receive the file.
I think it would be possible to do it depending on hyper terminal but i couldn't find way to run hyper and work on it on c# project ?
if any body can help on this way or another ?
best regards
sam
|
|
|
|
|
وينكون يا شباب
ليش ما حدا عم يرد
إذ ثير أني بادي هير=is there any body here
السلام يا زكرتية الحارة
لك ليش ما عم تشتغل
|
|
|
|