|
I would not call the example C# code complex.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: I would not call the example C# code complex.
Ok, but not sure how that is relevant to what I said about auto_ptr (which is not only used for that.)
|
|
|
|
|
It's not, just like talking about C++ in a C# forum isn't
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I am trying to create a C# widows form application that allows people to attend a group and sign up to one of the days they have. I would like the users to be able to sign in inputting their name, organisation, group and then using an automated time, to sign out. This data should then be copied to a database or file. they should then sign out later choosing their name from a drop down menu and again clicking a box so to get another automated time in which they will be able to sign out. The timein and timeout will be used to create a retention time in which the admin can access a page that displays this in a bar chart. There should be an option to register users to a group or create a group on the admin page.
|
|
|
|
|
..and your question is...?
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
And?
What have you tried?
Where are you stuck?
What help do you need?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have tried searching for tutorials and need help being pointed in the right direction.
I am stuck with trying to get the local database to accept data and ensuring my SQL commands are safe. I would also like help for what you would do if creating this application.
|
|
|
|
|
That doesn't tell us what you have tried: we have no idea what stage you have got to.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Please help. How to put two columns in a combo box (list Box, text box:mad. I work with VS2015, c# and MySql 5.7.
Attached part of the code.
private void comboBox1_Click (object sender, EventArgs e)
{
MySqlConnection conn;
myConnectionString = pwput;
conn = new MySql.Data.MySqlClient.MySqlConnection ();
conn.ConnectionString = myConnectionString;
try
{
conn.Open ();
}
catch (MySqlException ex)
{
switch (ex.Number)
{
case 0:
MessageBox.Show ("DO NOT SUCCE TO CONNECT ON SERVER, CLOSE PROGRAM TO TAKE A REPLY");
Close ();
break;
case 1042:
MessageBox.Show ("NOT ACTIVE SERVER, SUBSCRIBE SERVER PA REPEAT CONNECTING");
Close ();
break;
}
conn.Close ();
}
if (conn.State! = ConnectionState.Open)
{
MessageBox.Show ("DO NOT SUCCE TO CONNECT ON SERVER \ r \ n CLOSE PROGRAM TO TAKE READY \ r \ n");
}
else
{
AutoCompleteStringCollection kontoopis = new AutoCompleteStringCollection ();
string wnadidok = "SELECT idkonto, FROM account name";
loadingData = false;
DataTable dtkon = new DataTable ();
dtkon.Columns.Add ();
dtkon.Columns.Add ();
MySqlDataAdapter mdkon = new MySqlDataAdapter (wnadidok, conn);
mdkon.Fill (dtkon);
loadingData = true;
comboBox1.DataSource = dtkon;
// which field is shown in the table below
comboBox1.DisplayMember = "idkonto";
comboBox1.ValueMember = "idkonto";
comboBox1.DisplayMember = "title";
comboBox1.ValueMember = "title";
comboBox1.SelectedIndex = -1;
comboBox1.Text = "";
loadingData = false;
}
conn.Close ();
}
Thank you
|
|
|
|
|
|
|
your select query doesnt contans "title " but you have mapped the title to value member
the below lines repeating twice, however the compiler will takes only the latest assigned values
comboBox1.DisplayMember = "idkonto";
comboBox1.ValueMember = "idkonto";
comboBox1.DisplayMember = "title";
comboBox1.ValueMember = "title";
try concatenating the two columns in the select query as
string wnadidok = "SELECT idkonto + ' ' + title as combinedCol , title FROM [account name]";
and change the DisplayMember and ValueMember as
comboBox1.DisplayMember = "combinedCol";
comboBox1.ValueMember = "title";
|
|
|
|
|
|
welcome
|
|
|
|
|
I know very little about AD. I found this article but it's old.
We have a device that requires the user to log in. Currently, the usernames/passwords are stored in a table in the database on the device. In the table are also roles such as "Operator" and "Supervisor", and an Active checkbox.
We now have a requirement that if AD is configured/enabled, then use that to validate the user. This opens up some questions.
1) How can I tell in C# if AD is configured/enabled?
2) Is it possible using AD to store and retrieve the roles I mentioned as well as the Active checkbox?
The goal would be to not store this info locally on a device but to have validate and identify the user and device related information from outside the device.
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
It will probably be easier to use the System.DirectoryServices.AccountManagement[^] namespace. You can use Active Directory groups to represent the roles.
public static bool ValidateCredentials(string userName, string password)
{
using (var context = new PrincipalContext(ContextType.Domain))
{
return context.ValidateCredentials(userName, password);
}
}
public static bool IsUserActive(string userName)
{
using (var context = new PrincipalContext(ContextType.Domain))
{
var user = UserPrincipal.FindByIdentity(context, userName);
return user != null && user.Enabled == true;
}
}
public static bool IsUserInRole(string userName, string roleName)
{
using (var context = new PrincipalContext(ContextType.Domain))
{
var user = UserPrincipal.FindByIdentity(context, userName);
var group = GroupPrincipal.FindByIdentity(context, roleName);
return user != null && group != null && user.IsMemberOf(group);
}
}
To detect whether the computer is joined to a domain, you'll need to P/Invoke the NetGetJoinInformation[^] function:
.net - How to detect if machine is joined to domain (in C#)? - Stack Overflow[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
When you refer to Role, what exactly is that? Is a Role in the sense you're referring to something that can be defined by the System Admin?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Role is your concept, AD works with GROUPS and a user is a member of 1 or more groups, a heavy security requirement can be a nightmare. We had to get creative around the name of the groups to support department and role. Typically
Finance_Op = finance operations
Finance_RO = read only.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
The article you describe as "old" has #337 votes. There's a comment with code suggestions in Oct, 2016, which the author acknowledged.
Is it too much to ask that you review more than one article on CP (out of many) ? [^]. Or that you visit StackOverFlow, and sample possibly relevant sources.
"If not you, who ? If not now, when ?" (sometimes attributed to Hillel the Elder)
«While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)
|
|
|
|
|
BillWoodruff wrote: Is it too much to ask in this instance, probably.
|
|
|
|
|
I pointed out that it's old because AD has evolved over time. Some of the comments pointed out that there are newer ways of doing some of the things the article discussed.
BillWoodruff wrote: Is it too much to ask that you review more than one article on CP (out of many) ? [^]. Or that you visit StackOverFlow, and sample possibly relevant sources.
That's an assumption on your part that I haven't looked at other resources.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Having a AAA source like LDAP is how things should be done for any non-trival application with securables. It does a few things for you, such as de-obligating the engineer from concerns like identity and role tracking, and makes things grotesquely easier from an operations standpoint. If someone leaves the company, just disable 1 account rather than having to check each application and remove accounts.
While I respect Richard's advocacy of System.DirectoryServices.AccountManagement (S.DS.AM), I've played with the namespace some and, depending on the use case, have found it to be restrictive and slow. There are three namespaces for using AD in three different ways, and each has strengths and weaknesses. S.DS.AM is the newest library, and it has a number of helper functions out of the box and is streamlined a bit, but it interfaces with the MS ADSI interface, which is an entire operational layer that exists at a higher level than LDAP. The base namespace, System.DirectoryServices (S.DS) is less streamlined, but more flexible, but also leverages the ADSI interface.
I generally use System.DirectoryServices.Protocols (S.DS.P) since it doesn't touch ADSI and goes straight through as LDAP. The library is minimalist, so learning to use it can be tricky, but it is several orders of magnitude faster than the alternatives (and I mean hundreds), so if you find yourself working with multiple records it can be a life saver. It also de-couples you from Active Directory by targeting LDAP directly, which can be implemented in a few different ways.
Here's pretty comprehensive intro to S.DS.P if you're interested.:
Introduction to System.DirectoryServices.Protocols (S.DS.P)
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
..
modified 19-Nov-17 11:55am.
|
|
|
|
|
What "session code"?
What is it supposed to do?
When is it supposed to do it?
Remember: we know nothing about your project, and I for one am not going to wade through your whole project trying to to work what you haven't done!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|