|
try this, the only thing I can see different from what I've used.
search.Filter = "(SAMAccountName=" + userName + ")";
only two letters away from being an asset
|
|
|
|
|
thanks for the reply, but there is nothing wrong with the code as it is posted!!!
Using "samaccountname" as the filter criteria works everytime (read the code comments). Using anything else fails, I have tried fully compliant LDAP queries too.
I have no issue with the FindAll() method but would like to use this one (I figure that it is faster).
help!!!!
shwaguy
|
|
|
|
|
shwaguy wrote: there is nothing wrong with the code as it is posted!!!
Don't go getting you feathers up. If there is nothing wrong, then what is the question?
Perhaps you need to calm down and restate the question, more clearly since we are obviously not getting your meaning.
only two letters away from being an asset
|
|
|
|
|
I seem to get my feathers up when people reply, with the first thought that comes into their head, without actually reading the original post; it tends to destroy a thread.
Your post was not so bad, simple mistake...but 2 replies in a row (one not yours) that went down the same path is a bit frustrating.
Usually when a thread gets to 2 like this I never get an answer to the question......so I will ask later.
thanks
shwaguy
|
|
|
|
|
shwaguy wrote: so I will ask later.
I'll remember to ignore you then.
only two letters away from being an asset
|
|
|
|
|
thanks for letting me know you will ignore my threads...it was very useful on topic information (sc).
I understand that people make mistakes, but, when I get 3 knee jerk responses (responses that have NO input to the question) in a row I tend to figure noone will want to read the thread.
I twice stated that there was no issue with the existing code, but, you seemed to miss that. Your ego must be easily bruised if to be hurt by those exclamation marks.
-If a response is not the solution thats all good.
-If a response is correct solution thats all good.
-If the response is off topic becuase the poster did not bother to read the post....I think "I wish that the poster could delete the response, its a waste of reading time and clutters the original post"
You take offense way too easily. Just because you have 3500 posts does not mean I am kissing your butt for very poor, of topic, replies. I don't have anything against you either, I think you may have helped a lot of threads.
shwaguy
|
|
|
|
|
shwaguy wrote: I twice stated that there was no issue with the existing code,
Then why did you post it?
Go away, son, you bore me.
only two letters away from being an asset
|
|
|
|
|
You just have to feel like your right on this don't you? Here is the news, you are wrong again.
The code although correct did not suit my purpose. If you bothered to read the posting you would have noted that I commented out (with comments) the items that would not work, but wanted to work.
as previously stated: beat it.
|
|
|
|
|
|
Thanks, but the userName is valid, it was the first thing I checked: The variable (and query) I used for the search filter worked fine with "FindAll()"
The thread is closed now....thanks for the help.
|
|
|
|
|
It is proper to keep a thread even if you already found the solution. Someone later on might have the same type of problem and this thread could help them.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Hi Paul,
I agree. In this case no solution was found for the original question and the thread turned into an unreadable mess that would only serve to waste the time of someone seeking a solution.
Usually, I get good or great responses from this forum. People usually read, think then answer (even if the correct solution is not given). Maybe I just asked on a bad day.
shwaguy
|
|
|
|
|
shwaguy wrote: Maybe I just asked on a bad day.
Or, more likely, you asked a poorly defined question and are now upset and pouting.
only two letters away from being an asset
|
|
|
|
|
beatit fool....read the code comments of my original code and the posting. Your wrong, stop flaming.
I am starting to think taht a large portion of your 3500 posts were garbage posts.
|
|
|
|
|
shwaguy wrote: the original question
It did sound rather vague.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Putting aside the 2 replies I got being totally off topic:
- "what error message did you get?" - uh...none...I got a null value as stated.
- replace code that was stated as working search.Filter = "samaccountname=" + userName; with this other filter that works equally well too (blah, blah, blah).
Whats vague about the post?:
//this filter works
search.Filter = "samaccountname=" + userName;
//This below formats for the search filter result in result=null
//search.Filter = String.Format("(cn={0})", userName); //code project filter
//search.Filter = "cn=" + userName;
SearchResult result = search.FindOne();
shwaguy
|
|
|
|
|
The original post was rather vague. Not the ones that followed.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I've wanted to do this and come up with this code:
private void generatebut_Click(object sender, EventArgs e)<br />
{<br />
string[] strRandomIdeas;<br />
strRandomIdeas = new string[10];<br />
<br />
strRandomIdeas[0] = "Bus";<br />
strRandomIdeas[1] = "Animal";<br />
strRandomIdeas[2] = "Surfing";<br />
strRandomIdeas[3] = "Ride";<br />
strRandomIdeas[4] = "Vehicle";<br />
strRandomIdeas[5] = "House";<br />
strRandomIdeas[6] = "Gaming";<br />
strRandomIdeas[7] = "Flying";<br />
strRandomIdeas[8] = "Entertainment";<br />
strRandomIdeas[9] = "Music";<br />
<br />
Random RandomIdea = new Random(strRandomIdeas);<br />
txb1.Text = RandomIdea.Next();<br />
txb2.Text = RandomIdea.Next();<br />
<br />
if (txb1.Text = txb2.Text)<br />
{<br />
txb2.Text = RandomIdea.Next();<br />
}
However, I get numerous build errors and it basically doesn't work, can someone help me??
|
|
|
|
|
Well if you look at what Random.Next() returns, that would be your first spot to check, as its returning a random number and from your code that random number is going to be all over the place.
Read this for generating random numbers:
http://msdn2.microsoft.com/en-us/library/system.random.aspx[^]
Then adjust your code accordingly.
Once you have your random number, use that as your index for your strRandomIdeas array.
Also when comparing string, you should use the string.compare method.
if(string.compare(txb1.Text, txb2.Text) == 0)<br />
{<br />
}<br />
else<br />
{<br />
}
Just because we can; does not mean we should.
|
|
|
|
|
Thankyou for the help, but the problematic code is this:
Random RandomIdea = new Random(strRandomIdeas);<br />
txb1.Text = RandomIdea.Next();<br />
txb2.Text = RandomIdea.Next();
Random commands are a bit confusing and this just expands the problem, I've checked the msdn site, but it didn't help, is there any way I can debug this?
|
|
|
|
|
Rewrite your code as follows:
private void generatebut_Click(object sender, EventArgs e)<br />
{<br />
string[] strRandomIdeas;<br />
strRandomIdeas = new string[10];<br />
<br />
strRandomIdeas[0] = "Bus";<br />
strRandomIdeas[1] = "Animal";<br />
strRandomIdeas[2] = "Surfing";<br />
strRandomIdeas[3] = "Ride";<br />
strRandomIdeas[4] = "Vehicle";<br />
strRandomIdeas[5] = "House";<br />
strRandomIdeas[6] = "Gaming";<br />
strRandomIdeas[7] = "Flying";<br />
strRandomIdeas[8] = "Entertainment";<br />
strRandomIdeas[9] = "Music";<br />
<br />
Random RandomIdea = new Random();<br />
<br />
int indexID = RandomIdea.Next(0,strRandomIdeas.Length -1);<br />
<br />
string Text1 = strRandomIdeas[indexID];<br />
<br />
indexID = RandomIdea.Next(0, strRandomIdeas.Length - 1);<br />
string Text2 = strRandomIdeas[indexID];<br />
<br />
if (string.Compare(Text1, Text2) == 0)<br />
{<br />
indexID = RandomIdea.Next(0, strRandomIdeas.length -1);<br />
Text2 = strRandomIdeas[indexID];<br />
}<br />
}
This code compiles and returns your random strings.
Just because we can; does not mean we should.
modified on Friday, December 28, 2007 11:54:43 AM
|
|
|
|
|
DSdragondude wrote: Random RandomIdea = new Random(strRandomIdeas);
The documentation clearly shows:
1. Random constructor takes either no argument or an integer.
2. Random.Next() always returns an integer.
Hence, use the array bounds to limit the range Random.Next() will use, and appply its
return value as an index in your array.
|
|
|
|
|
Hi,
This is more of a theory question i guess. I've recently been looking at some old code and trying to improve it. I've always been told you should dispose of objects once you've finished with them, but never have as i've only been working on small projects.
However, its came time for me to start improving on this. In one section of my code i create a List<string> and pass it to my sql statement builder. My understanding is that now i have 2 Lists in memory, one used in the sql statements method and one in the method i used to create it.
Would it be better to pass it to the sql statements method as a ref and then clear its list at the end of the method i created it in? or just pass it normally and clear it in both methods?
Regards,
Gareth.
|
|
|
|
|
gareth111 wrote: create a List and pass it to my sql statement builder
If you're really interested in building better code, it would be wiser to use Stored Procedures and avoid other messes also.
only two letters away from being an asset
|
|
|
|
|
Mark,
I have used stored procs in other projects. The reason im not using them is because i think its far easier to use a sql statement class that has 5 or so methods than to use stored procs that has 20 or so.
Regards,
Gareth
|
|
|
|