|
here im getting active directory users ? i want to get that user active or inactive in that..How can we know. any property to use like,,
oSearcher.PropertiesToLoad.Add("samaccountname");
here my code, to get all users...
public Hashtable GetAllUsers(string ldapServerName)<br />
{ <br />
string _ldapServerName = ldapServerName;<br />
DirectoryEntry oRoot;<br />
oRoot = new DirectoryEntry(ldapServerName);<br />
<br />
DirectorySearcher oSearcher = new DirectorySearcher(oRoot);<br />
SearchResultCollection oResults ;<br />
Hashtable RetArray =new Hashtable();<br />
try<br />
{<br />
oSearcher.SearchScope = SearchScope.Subtree;<br />
oSearcher.Filter = "(&(objectClass=user) (objectCategory=person))";<br />
<br />
oSearcher.PropertiesToLoad.Add("name");<br />
oSearcher.PropertiesToLoad.Add("samaccountname");<br />
oSearcher.PropertiesToLoad.Add("cn"); <br />
oResults = oSearcher.FindAll();<br />
foreach (SearchResult oResult in oResults)<br />
{<br />
if (oResult.GetDirectoryEntry().Properties["samaccountname"].Value != null)<br />
{<br />
RetArray.Add(oResult.GetDirectoryEntry().Properties["samaccountname"].Value,<br />
oResult.GetDirectoryEntry().Properties["userAccountControl"].Value);<br />
}<br />
}<br />
}<br />
catch(Exception e)<br />
{<br />
MessageBox.Show("Error is " + e.Message);<br />
return RetArray;<br />
}<br />
return RetArray;<br />
}
-------------------------------------------------------------------
here get log in ,...can i use that here also???
DirectoryEntry entry = new DirectoryEntry(< LDapPath>,< username >, < pwd > );
try
{
// Bind to the native AdsObject to force authentication.
Object obj = entry.NativeObject;
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + txtUserName.Text + ")";
search.PropertiesToLoad.Add("name");
SearchResult result = search.FindOne();
if (null == result)
{
MessageBox.Show("User doesn't Exit.");
}
else
{
// Update the new path to the user in the directory
MessageBox.Show("Loged Succesfully user " + (String)result.Properties["name"][0]);
}
}
catch (Exception ex)
{
MessageBox.Show("Error authenticating. \\n"+ex.Message);
}
Thnks in advance!!!
|
|
|
|
|
i am new to programming, so plz help me.
I had design a wordpad or notepad editor, in this a user can fix the number of character in line, like if he sets chracter to 65 then only 65 chracters will appear in that line and further character will starts from next line.
so, at end of line instead of bringing the whole word to next lines it cuts the word(means if 65 character completed it force rest letters to next line). The word got cut.
so, how to solve this problem. So that, the whole word come to next line.
Help me.
|
|
|
|
|
You can check out one version of the WordWrap and LIne Breaking algorithm here:
http://www.velocityreviews.com/forums/t20370-word-wrap-line-break-code-and-algorithm-for-c.html
|
|
|
|
|
you need to search first for the '/n' char which mean a new line. then you cut the word you need to transfer and put it in the apt place
|
|
|
|
|
Hi
I have a strange problem.In an application ,I have a login process and I'd like to show the progress of this process on a progress form using a progress bar and a label describing what is going on.Thus I put a progress form in my project and whenever this form is activated starts the login process and listens to a progress event that tells it to refresh the controls according to the progress.
There's a LoginFailedException in my app that is thrown whenever the username and/or the password is incorrect.I've handled this exception by showing a message box.Every time I debug my project using VS2003 IDE and provide some incorrect information It works fine and shows me the message box but when I exceute the exe file directly ,an unhandled exception is thrown just like there is no exception handler available.
What is wrong with my program?
please help me.
|
|
|
|
|
Hard to say, without seeing some code.
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 )
|
|
|
|
|
Here it is :
In my login form:
<br />
private void OnOKButtonClicked()<br />
{ <br />
try<br />
{<br />
this.Cursor=Cursors.WaitCursor;<br />
progressForm.Login(this.txtUsername.Text,this.txtPassword.Text) ;<br />
this.Cursor=Cursors.Default;<br />
this.Close();<br />
}<br />
catch(LoginFailedException)<br />
{ <br />
this.Cursor=Cursors.Default;<br />
MessageBox.Show("Invalid username and/or password.");<br />
}<br />
catch(Exception exp)<br />
{<br />
new ExceptionViewForm(exp).ShowDialog();<br />
}<br />
}
In my progress from:
<br />
internal static void Login(string username,string password)<br />
{<br />
progressForm frm=new progressForm() ;<br />
frm.username=username;<br />
frm.password=password;<br />
frm.ShowDialog(); <br />
}<br />
<br />
protected override void OnActivated(EventArgs e)<br />
{<br />
if(! activated)<br />
{ <br />
LoginForm.engine=<br />
LoginProcess.Instance.Login(this.username,this.password); <br />
}<br />
} <br />
|
|
|
|
|
And what is the exception when it is run standalone? When you run it stand alone is it a debug or release build?
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
* Reading: Developer Day 5
Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton
My website
|
|
|
|
|
Hi
Exception is LoginFailedException and the stand alone program has been built using debug configuration.
|
|
|
|
|
Hi!Friends...Now Im working with datalist.In it I have added only one image button control..how come I knonw which image is clicked in a datalist..please help me firends..
Hi,Im Razana
|
|
|
|
|
winforms or ASP.NET ?
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
i used a quicktime object in my project to show 3 file in .mov extention.
my form object is axQTControl1 and one btn to play movie and one btn to set nevt movie url
i set the first clip url in form.load() and play it whitout problem.
when click next clip btn and click play i get the System.AccessViolationException
"System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.AxHost.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageA(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at QuickPlayer.Program.Main() in D:\\MyDoc\\My Project\\Q\\QuickPlayer\\QuickPlayer\\Program.cs:line 24"
please help me.
|
|
|
|
|
|
Good Day Sir/Maam,
<br />
DateTime StartTime = DateTime.Now;<br />
for (int i = 0; i <= List.Length - 2; i++)<br />
{<br />
for (int j = 0; j <= List.Length - 2 - i; j++)<br />
if (List[j + 1] < List[j])<br />
Swap(ref List[j], ref List[j + 1]);<br />
}<br />
DateTime EndTime = DateTime.Now;<br />
TimeSpan Duration = EndTime - StartTime;<br />
This is a bubble sort algorithm, I want to get the total duration of the sorting in Milliseconds. But the sorting was too fast that I got a 0 MS duration.
Can I get the duration in Nanoseconds using Timespan?
|
|
|
|
|
|
Ummmm.. no? It's a limitation of the hardware clock? (Others know more about it than I.)
But I'll add that you probably don't need to write your own sort algorithm (unless it's for a class project or something) because the ones built into .net are probably better than anything you or I could write.
See if something like System.Collections.Generic.List<int> will work for you, it has a Sort() method.
It just won't help you learn how to perform a sort.
|
|
|
|
|
Uhmm. I'm making a Sorting Emulator for educational purposes to present how a sorting algorithm works.
This is a class project for my course Analysis of Algorithms. Hehe.
Anyways, StopWatch class works great. Thanks! 6 ticks = 600 nanoseconds.
|
|
|
|
|
Hi, to see why regular timers dont help you here, you may want to read my timers article.
|
|
|
|
|
Hi,
I want to create an add-in for Visual Studio that : when I right-click on C# document, it will show the context menu strip which has my items in.
Thank a lot
imagic
|
|
|
|
|
I have a problem when reading a Streamreader object into a string:
<br />
private string GetStringFromURL(string url)<br />
{<br />
string strOut = "";<br />
<br />
HttpWebRequest webRequest;<br />
HttpWebResponse webResponse;<br />
Stream responseStream;<br />
webRequest = (HttpWebRequest)WebRequest.Create(url);
webResponse = (HttpWebResponse)webRequest.GetResponse();
responseStream = webResponse.GetResponseStream();
string responseEncoding = webResponse.ContentEncoding.Trim();<br />
if (responseEncoding.Length == 0) responseEncoding = "us-ascii";<br />
StreamReader sr = new StreamReader(responseStream, System.Text.Encoding.GetEncoding(responseEncoding));<br />
<br />
sr.BaseStream.ReadTimeout = 3000;
try<br />
{<br />
strOut = sr.ReadToEnd();<br />
}<br />
catch (WebException ioe)<br />
{<br />
MessageBox.Show(ioe.Message.ToString());<br />
}<br />
<br />
<br />
webResponse.Close();<br />
responseStream.Close();<br />
sr.Close();<br />
<br />
<br />
return strOut;<br />
<br />
}<br />
<br />
The above code doesn't cause the Messagebox to actually pop up. When I pause the code I find it spends alot of it's time in the catch() area though. On closer inspection of the 'sr' object, it seems to have a problem:
<br />
BaseStream = Cannot evaluate expression because a native frame is on top of the call stack.<br />
Is there a way of checking for this error with an 'if' statement so that this process doesn't take so long? (it does eventually time out but this is v. slow. The url I'm reading into the string is:
http://www.atomintersoft.com/products/alive-proxy/proxy-list/?p=4[^]
Any help or advice much appreciated!!
Gerry
|
|
|
|
|
I see that you set the ReadTimeout on the response stream, but that is the timeout for reading data from the stream, not the timeout for ding the request.
Set the Timeout property in the HttpWebRequest object before calling GetResponse .
---
single minded; short sighted; long gone;
|
|
|
|
|
Good Day Sir/Maam,
I have a ListView on my program and it has 3 columns.
I add items in the end of the List. Using .add(); command. But when the list is gets too much item, the vertical scroll bar will activate.
What I want is to FOCUS the ListView on the Last item added. So that the last item will not be hidden from view. (You need to click the vertical scroll bar to view the last item)
Thank you.
|
|
|
|
|
Use EnsureVisible() [^] to ensure a specific item (in your case, the most recently added one) is visible.
/ravi
|
|
|
|
|
Cool. It worked as expected. Thank you sir Rabi!
|
|
|
|
|
Hi Sirs,
I want to know how can we unpack the C# dll files i mean i want to c all the classes in all namespaces like System.IO etc. in java we can easily do it but i don't know how can we do it in .NEt please help me in this regard..
thanx.
Pravo
|
|
|
|