|
You can loop thru and write your own logic to fill in the array(s) you like.
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
Hi,
Im using C#.Net 2003,im using windows 2000 operating system.. i retrieved all the available windows user by using the following code and listed in the listbox..
private void button2_Click(object sender, System.EventArgs e)
{
using(DirectoryEntry root = new DirectoryEntry("WinNT://node-10"))
{
foreach (DirectoryEntry child in root.Children)
{
if (child.SchemaClassName == "User")
{
listBox1.Items.Add(child.Name);
}
}
}
}
Actually i want to check is it the right user or not from the C#.Net by programmatically..
in textbox1 im entering the username and
in textbox2 im entering the password
on clicking the ok button it should check whether the entered username and password are the right one or not,if it is the right one, then in messagebox("Valid user") else in messagebox("Invaliduser").and also mention if need to refer any namespaces over here...How should i achieve this one...plz help me..its urgent...
rgrds
Kanna..
|
|
|
|
|
Dotnetkanna wrote: plz help me..its urgent...
I wish I had a dollar for every CP post that ends with that.
Why do you want to do this ? I'd be sad if it were possible to write an app that tells a user on a PC the username and password of all users on that machine. But, why would you require someone to log on using creditials they have already logged on with ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: But, why would you require someone to log on using creditials they have already logged on with ?
I was just thinking that.
|
|
|
|
|
Hi,
Thanks for your reply.I want to check is that particular user is available in that operating system or not.im not going to login.I want jus check is that user is existing or not in the operating system by programmatically.any idea please..
rgrds
Kanna..
|
|
|
|
|
Hi,
Thanks for your reply.I want to check is that particular user is available in that operating system or not.im not going to login.I want jus check is that user is existing or not in the operating system by programmatically.any idea please..
rgrds
Kanna..
|
|
|
|
|
As I said, I'd eat my hat if the system allows you to ask for the passwords of all users. The usernames cannot be hidden, they are written in the Documents and Settings folder.
What you want to do makes no sense, and is unlikely to be supported. Why would you require someone give their password to prove that the system has correctly found their username ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
Actually im doing one process for that i want to check whether the user is exists or not in the operating system..im passing the username and password to this tag,if it is the right user means the program is running well if it is the invalid user means im getting the error..before do that process i want to check whether that user is available or not..for this i want to check this one...
regards
Kanna..
|
|
|
|
|
While I am not sure this will fit what you need I do something similar in one of the applications I develop and you may be able to tweak this.
Basically this application has functionality within it that could feasible be very destructive in the wrong hands. As a result of this I need to ensure that the user sat at the machine is the actual user that is logged on. In order to do this when the application opens it prompts them to enter their windows authentication information.
Internally the code uses the following:
const int LOGON32_LOGON_INTERACTIVE = 2;
const int LOGON32_PROVIDER_DEFAULT = 0;
[DllImport("advapi32.dll", SetLastError=true)]
private static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
private void DoLogonCheck()
{
this.logonAttemptCount++;
IntPtr phToken = IntPtr.Zero;
bool logonRes = LogonUser(
txtDomainUserName.Text,
txtDomainName.Text,
txtDomainPassword.Text,
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
ref phToken);
if (logonRes)
{
this.DialogResult = DialogResult.OK;
this.domainUserName = txtDomainUserName.Text;
this.domainName = txtDomainName.Text;
}
else if ((!logonRes) && (this.logonAttemptCount < this.maxLogonAttempts))
{
txtDomainPassword.Text = string.Empty;
txtDomainPassword.Focus();
}
else if ((!logonRes) && (this.logonAttemptCount >= this.maxLogonAttempts))
{
System.Windows.Forms.Application.Exit();
}
}
Externally to this method the code also checks that the given user name is the same user that is under the Environment.UserName object.
As an additional level of security the form that results from successful authentication has a timeout that will close it after X seconds of inactivity. This means that if the user logs in and then gets up an walks away the application isnt open to any passer by.
In theory I believe that this code could also be used to check the logon for a user that is not currently logged on, however I have never used it that way so I cannot say for certain
|
|
|
|
|
Hi,
Thanks for ur Valuable reply.while im using ur code im getting the error on
this.logonAttemptCount++;
.
.
.
this.domainUserName = txtDomainUserName.Text;
this.domainName = txtDomainName.Text;
.
.
else if ((!logonRes) && (this.logonAttemptCount < this.maxLogonAttempts))
.
.
else if ((!logonRes) && (this.logonAttemptCount >= this.maxLogonAttempts))
Im getting error on these lines as "does not contain definition for 'logonAttemptCount'" and "does not contain definition for 'domainUserName'" and "does not contain definition for 'domainName'"...How to i solve this did i need to add any references other than this
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.DirectoryServices;
using System.Runtime.InteropServices;
using System.Web.Security;
using System.Security.Principal;
If yes, give me the detail and give me a solution to the error..plz
rgrds
Kanna..
|
|
|
|
|
those three variables are class level items, so if you want to use logon attempt counts and need to keep a record of the entered user/domain name you will need them (depending on yor class design)
As an example:
using....
using....
using....
namespace Widgets
{
class LogonCheck
{
private string domainUserName;
private string domainName;
private int logonAttemptCount;
public LogonCheck()
{
this.domainUserName = string.Empty;
this.domainName = string.Empty;
this.logonAttemptCount = 0;
}
public DoLogonCheck()
{
}
}
}
That about covers it, however depending on your design you may or may not need these or it may be better to declare these as static
|
|
|
|
|
How can I use Formula in crystal Report 9
|
|
|
|
|
Hi.
I have an auto-increment database field with 5 digits. (example. "00001", "00002", "00003")
But every time i query it using C#, and place it in text boxes or in labels, it always removes the zeros, so I always end up with just "1", "2", "3", etc.
I'm currently using microsoft access 2003. The error also occurred when I used mySQL.
Anyone know how to set form objects to recognize the zeros in the values?
Thanks in advance.
|
|
|
|
|
Its only an error if the value is a string. If it's a number at any point in the process, the 0s are meaningless, and therefore discarded.
You can use string.Format to format a string to have as many zeros as it needs to fit this format.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi every one! I've create my own C++ class and push it to the dll. I need to get only one function from it. It fills many variables of this class. I need to get them, but i don know how. One of this var is vector<string> how can i get this data? I have read the article about calling functions from dll, but i can't get data from my var.
Thanks.
|
|
|
|
|
A vector is a C++ class, you'd need to push out an array ( which is what the vector is wrapping ) instead.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi all
i have got two forms one up on the other..
now if i click on the form which is behind the form which is on top is going behind..
i dont want that to happen...
i want the form which is in front should take info. and then active the form behind....
please help me for the necessary..
thanks bye
|
|
|
|
|
I think you need to show a from on top. Considering form1 is the Form object that you want to keep on top of form2
use form1.TopMost = true before calling form1.Show() or form1.ShowDialog()
|
|
|
|
|
If form2 is a child of form1, set the owner of form2 to be form1. Then, form2 will always stay above, as achild window should.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I'm create an instance called shtb like this:
public form1()
{
InitializeComponent();
SyntaxHighlightingTextBox shtb = new SyntaxHighlightingTextBox();
...
}
Later in the script, i tried to use the instance shtb like this:
static string strMyOriginalScript = "";
private void form1_Load(object sender, System.EventArgs e)
{
strMyOriginalScript = shtb.Text;
}
When ever i try to build the solution, i keep getting the error:
'Editing Area' does not exist in the current context
Where im i going wrong? Can anyone help me with atleast this?
|
|
|
|
|
I tried editing like this also:
static string strMyOriginalScript = "";
private void form1_Load(object sender, System.EventArgs e)
{
SyntaxHighlightingTextBox shtb;
strMyOriginalScript = shtb.Text;
}
still didn't work... where im i going wrong?
|
|
|
|
|
the problem is with the object not with the string,
define the object outside the constructor, just below the definition of the class
public class form1
{
SyntaxHighlightingTextBox shtb = null;
..................
.............
...
and then in the constructor you initialize the object
public form1()
{
InitializeComponent();
shtb = new SyntaxHighlightingTextBox();
...
Andres
"Learn from the mistakes of others.
You can't live long enough to make them all yourself."
"Failure doesn't mean I'm a failure, It does mean I have not yet succeeded;
Failure doesn't mean that I should give up, It does mean that I should try harder;
Failure doesn't mean that I will never make it, It does mean that I need more practice".
Thank you for helping.
|
|
|
|
|
Latheesan wrote: SyntaxHighlightingTextBox shtb = new SyntaxHighlightingTextBox();
If this is a control, you need to set it's location on the form and add it to the forms Controls collection. Otherwise, it's just a local variable that disappears as soon as it goes out of scope. Even if it was a member, if it's not in the Controls collection, it's not on the form
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Yes, it was a control that was provided from an external .dll
so, i added the dll into my project reference first and then, in the top of the form1.cs, i have this code:
using SyntaxHighlighting;
and iniside the form1_Load(); i have this code now:
Controls.Add(shtb);
Yet, i still get that error "The name 'shtb' does not exist in the current context"
|
|
|
|
|
The error that was pointed out to you is still the case. If you create it in your constructor, locally, then it doesn't exist anymore in your load event. You should call the constructor in your load event. Scratch that. You buy a book on VB.NET, read it, work through it, and start another project when you've learned some basics. If you don't understand variable scoping, you frankly should not be writing code, sorry.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|