|
Sounds like you have a problem with DNS then. In your rootDSE binding string, try specifying the full DNS name for that server or domain. Or you can also get the "dnsHostName" property from the rootDSE and bind explicitly to that when you bind to the group.
e.g.,
string dnsName = rootDSE.Properties["dnsHostName"].Value.Tostring();
string groupPath = string.format( "LDAP://{0}/{1},{2}", dnsName, groupName, namingContext );
DirectoryEntry group = new DirectoryEntry( groupPath );
If that doesn't work, then you *definately* have a problem with DNS.
|
|
|
|
|
Again, Thank you so much. I've got it (almost)working !
But like you said before, I only get one name. Even though I use a foreach-statement.
Here's my code: ("cu4it" is my domain-name")
string eigenstring = "LDAP://cu4it/CN="+strGroup+",CN=Users,DC=Cu4IT,DC=tld";<br />
DirectoryEntry ent = new DirectoryEntry(eigenstring);<br />
<br />
DirectorySearcher mySearcher = new DirectorySearcher(ent);<br />
<br />
SearchResultCollection coll = mySearcher.FindAll();<br />
foreach (SearchResult rs in coll)<br />
{<br />
ResultPropertyCollection resultPropColl = rs.Properties;<br />
foreach( Object memberColl in resultPropColl["member"])<br />
{<br />
DirectoryEntry gpMemberEntry = new DirectoryEntry("LDAP://cu4it/"+ <br />
memberColl);<br />
System.DirectoryServices.PropertyCollection userProps = <br />
gpMemberEntry.Properties;<br />
object obVal = userProps["sAMAccountName"].Value;<br />
if (null != obVal)<br />
{<br />
slet.Add(obVal.ToString());<br />
}<br />
}<br />
}
What's your tip/trick to list all subscribed users to a group?
Greetingz
|
|
|
|
|
Hello ;
I'm programming a .net application and i'm using a matlab files ; on using this files (always in a threads) i receive a warning messages like "Warning matlab : Fatal error on start up" or " Failed java matlab services".
Please can u tell me the explication of such errors.
Thank's a lot
|
|
|
|
|
Hi all,
when i am executing the following code the, if the function invoked returning other than null, it is working fine. if it returns null, then it throws the object reference not found exception. please help.
string functionName ="GetMRN";
System.Reflection.MethodInfo methodinfo;
methodinfo = this.GetType().GetMethod(functionName);
objParamArr[0] = Param2;
objParamArr[1]=param2;
string strResult = methodinfo.Invoke(Invoke(this,objParamArr).ToString();
regards.
HAsan
Contact him at: hasansheik@hotmail.com
hasansheik@yahoo.co.in
hasansheik@lycos.com
|
|
|
|
|
|
Hi all,
when i am executing the following code the, if the function invoked returning other than null, it is working fine. if it returns null, then it throws the object reference not found exception. please help.
string functionName ="GetMRN";
System.Reflection.MethodInfo methodinfo;
methodinfo = this.GetType().GetMethod(functionName);
objParamArr[0] = Param2;
objParamArr[1]=param2;
string strResult = methodinfo.Invoke(Invoke(this,objParamArr).ToString();
Contact him at: hasansheik@hotmail.com
hasansheik@yahoo.co.in
hasansheik@lycos.com
|
|
|
|
|
I am writing console batch application which does intense processsing on bitmap. I would like to know the preffered way of dealing with Min and Max values, its good if I can save a microsecond as batch application runs for a week.
minValue = Math.Min ( val1, val2 )<br />
<br />
minValue = val1 < val2 ? val1 : val2;
Also is it possible to know which one is faster by examining metadata?
REgards.
MaulikCE
|
|
|
|
|
|
What about others, "double" and "float"? One more, is there any performance difference between IF ELSE and CONDITIONAL EXPRESSION?
|
|
|
|
|
|
Here is the authentic word, the second way (of using If-else) is almost 100% faster than the first method (of using Static method of Math). Here is how I arrived at the result.
Had a simple project with two buttons and two labels, with the following event-handlers for their click events:
private void button1_Click(object sender, System.EventArgs e)
{
int minValue;
int val1 = 5;
int val2 = 7;
DateTime time1 = DateTime.Now;
for(long i=0; i<1000000000; i++)
{
minValue = Math.Min ( val1, val2 );
}
DateTime time2 = DateTime.Now;
TimeSpan diff1 = time2 - time1;
label1.Text = diff1.Seconds.ToString();
}
private void button2_Click(object sender, System.EventArgs e)
{
int minValue;
int val1 = 5;
int val2 = 7;
DateTime time1 = DateTime.Now;
for(long i=0; i<1000000000; i++)
{
minValue = val1 < val2 ? val1 : val2;
}
DateTime time2 = DateTime.Now;
TimeSpan diff1 = time2 - time1;
label2.Text = diff1.Seconds.ToString();
}
This means that both the methods are compared by using the for loop for 10 billion iterations of the respective calculations. And the results are: the first method took 12 seconds whereas the second method took just 7 seconds.
So, you can safely use the second method.
|
|
|
|
|
Just curious, but what are the results if you randomly generated numbers instead of using the same two constant numbers over and over again?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yes, I compared the performance of the said two methods by using random numbers. Here is the code which I used (this time I used only 1 million iterations instead of 10 billion iterations because of time-consuming random number generation process):
private void button1_Click(object sender, System.EventArgs e)
{
DateTime time1 = DateTime.Now;
for(long i=0; i<1000000; i++)
{
int val1 = Random1To99();
int val2 = Random1To99();
int minValue = Math.Min ( val1, val2 );
}
DateTime time2 = DateTime.Now;
TimeSpan diff1 = time2 - time1;
label1.Text = diff1.Seconds.ToString();
}
private void button2_Click(object sender, System.EventArgs e)
{
DateTime time1 = DateTime.Now;
for(long i=0; i<1000000; i++)
{
int val1 = Random1To99();
int val2 = Random1To99();
int minValue = val1 < val2 ? val1 : val2;
}
DateTime time2 = DateTime.Now;
TimeSpan diff1 = time2 - time1;
label2.Text = diff1.Seconds.ToString();
}
And, the method to generate the random numbers is as under (for the sake of simplicity, this method generates random numbers in the range of 1 to 99 only; secondly, I declared mySeed variable at the class level to try to get the "real" random numbers by using a real different seed every time):
private int mySeed = 0;
private int Random1To99()
{
DateTime dt = DateTime.Now;
mySeed += (int)(dt.Millisecond);
Random rnd = new Random(mySeed);
return (int) rnd.Next(1, 100);
}
This time, both the methods are taking the same time of 37 seconds on my machine. The result is the same even though I tried it a few times.
The reason appears to be that the generation of one random number takes perhaps 1000 to 10000 times more time than either of the methods being compared! And, then use this for 1 million times!! In the end, what one finds is that out of 37 seconds taken for the aforesaid operation, perhaps 99.999% of the processing time is taken only for the random number generations and the remaining appx. 0.0001% time is being compared for the said two methods. So, expectedly, we get the same time of about 37 seconds for the above two methods.
To conclude, what I personally feel is that once it is accepted that the second method of if-else takes less time for any given combination of two numbers as compared to the first method of Math static function, then this result would broadly be the same even for any other combination of randomly selected numbers.
Regards
|
|
|
|
|
That's what I though would happen. What I think the comiler did to your original code, was that since your using contant numbers, the "?:" statement was optimized into the only result possible for that statement and was replaced by a simple numerical assignment.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Your code was slowed down because you kept killing and recreating a new RNG with every number you generated and used limits on the range of numbers returned. You also have the extra overhead of making a method call to create a new RNG, seed it, and return a number. This wasn't necessary since we weren't testing the performance of the RNG functions.
If you want wanted to compare the two methods on the exact same stream of numbers (and do it quickly!), then you have to create an RNG with a known seed value and retain it throughout the entire test and minimize the number of calculations that it has to do to return a number.
I ran similar code to yours, running 1 Billion iterations in just under one minute:
int Num1, Num2, Num3;
Stopwatch timer = new Stopwatch();
Random RNG = new Random(3456);
Console.WriteLine(DateTime.Now.ToString());
timer.Start();
for (int IterationsRemaining = 1000000000; IterationsRemaining >= 0; IterationsRemaining--)
{
Num1 = RNG.Next();
Num2 = RNG.Next();
Num3 = (Num1 > Num2) ? Num2 : Num1;
}
timer.Stop();
Console.WriteLine(DateTime.Now.ToString());
Console.WriteLine(timer.Elapsed.ToString());
Using the known seed value, rerunning this code with the only change being the Num3= line, the RNG will generate the exact same string of numbers.
The results I got on a Dell GX270, C# 2005, running 3 passes of 1 Billion iterations each:
Release compiled code: (int types)
Math.Min: 46.11 47.02 45.92 seconds (Avg: 46.35 seconds)
?: operator: 39.78 40.04 39.37 seconds (Avg: 39.73 seconds)
Here's something interesting:
Release compiled code: (double types)
Math.Min: 114.10 113.66 111.77 seconds (Avg: 113.17 seconds)
?: operator: 56.91 56.95 56.97 seconds (Avg: 56.94 seconds)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
In fact, I tried the aforesaid code with the floating point numbers also, by replacing the first lines of the code (above) with the following sample code:
float minValue;
float val1 = 5.3214F;
float val2 = 7.7564F;
The result is still the same. The second method (i.e., the if-else method) is almost 100% faster than the first method (i.e., the Static Math method). The practical results on my machine were 17 seconds and 8 seconds respectively for 10 billion iterations for the said float numbers for the aforesaid two methods.
Regards
|
|
|
|
|
Without further investigation the second one would seem faster. If you really want to know for sure construct a simple test example that just reads each pixel on a bitmap and runs one or the other comparison and time the event.
However I would caution you about attempting optimization like this because premature optimization is evil. Without profiling tools trying to optmize can lead to confusing code and worse even worse performance (ie. producing bogus output, crashing, etc). The best optimization might happen outside of this code and quite possibly be in another part of the loop. Or ultimately, this is a "hardware bound" problem where no matter how much tweaking you do to code you are better off taking the amount of money they would have paid you to tweak code and buying new hardware with it.
|
|
|
|
|
Hi.I need an algorithm in C# or any other language for 2Dimensional Cutting Stock Problem.Please help me cause I m very worried about the result of my work.
|
|
|
|
|
Hi...
I have file with map in MapInfo format... How can i read this file using C#...
and how can i draw a map on form?
Greetings
Yarns
|
|
|
|
|
Can anyone guide me how to create auto hide feature.or can anyone give me sample code to create auto hide fucntionality in C# or in VB.NET.
Umair
|
|
|
|
|
If I understand correctly, what you want to know about is a window which hides automatically when the focus is moved away from it (for example certain windows in the IDE of Visual Studio .NET). If it is so, you may try to have a look at the source code here[^]), though you may have to go through tons of code.
|
|
|
|
|
Yes you understand correct,i need same effect.But i have found my own way,its quites simple and quites easy.Thx anyways
Umair
|
|
|
|
|
how did you do? Can you explain.
|
|
|
|
|
Is it possible to paint over the top of a child component without overriding the OnPaint function for the child component?
|
|
|
|
|