- foreach (SearchResult result in search.FindAll())
-
{
-
-
//pieces = result.Properties["samaccountname"][0].ToString().Split(new Char[] { '\'' });
-
//for (int i = 0; i < pieces.GetLength(0); i++)
-
//{
-
//name = name + pieces[i];
-
//}
-
-
manager.Items.Add(new ListItem(name, result.Properties["samaccountname"][0].ToString()));
-
-
name = "";
This bit of code take the aduser samaccount and gets the number of characters and sets an absolute length for the drowdownlist(manager) to display the names. Well it has stopped working and I have no clue why.
The errors are as follows: Cannot implicity convert type 'string[]' to 'string'
'string' does not contain a definition for 'GetLength'
Any help asap would be really nice.
14 1845
Well, you didn't show us the definition of pieces, but I believe that pieces is delcared as a string, and you are trying to use it as an array.
Make sure that pieces is defined as a string[].
Also, I'm not sure why all your code is commented out.
Well, you didn't show us the definition of pieces, but I believe that pieces is delcared as a string, and you are trying to use it as an array.
Make sure that pieces is defined as a string[].
Also, I'm not sure why all your code is commented out.
The whole thing was crashing and I wanted to see if it still worked without this and it just displays a small drowdown list with no names but a scroll bar and space for names. Could you be more specific about pieces to be defined as string[]. This isn't my code it was the guys before me and I am clueless on c#.
Also this is the only place pieves is used. Everything you see is everything you get.
It actually doesn't look like .NET?
I've never used GetLength() before, always just used .Length
string[] .Length will return the number of elements in the array (number of strings in the array)
string .Length returns the number of characters in the string.
It actually doesn't look like .NET?
I've never used GetLength() before, always just used .Length
string[] .Length will return the number of elements in the array (number of strings in the array)
string .Length returns the number of characters in the string.
When I used .Length and it needs more specific parameters in my opinion. Like I said C# is not my cup of tea and this is old .NET. This program is a few years old with hardcoded emails and such. Well one day after I loaded VS 2008 up and opened the IIS and edited one of the emails it was sending too(I am in the middle of writing all these programs correctly for future reference) and saved it and it didn't work. And ever since have had this issue. I need to get it done because people are unhappy that it's not working and I hadn't realized it wasn't working until just a few days ago.
Did this use to work? or has it never worked?
pieces has to be defined somewhere. Right click on it and select "go to definition" or something like that.
@Plater:
Maybe it's this method, but I've never seen it either.
I forgot it wasn't in my copied code. But it's still not all that helpful. - DirectoryEntry entry = new DirectoryEntry("LDAP://OU=DAXCON,DC=hq,DC=local", "username", "password");
-
DirectorySearcher search = new DirectorySearcher(entry);
-
-
search.Filter = "(&(objectclass=organizationalPerson) (mail=*daxcon.com)(!(useraccountcontrol=514)) (sn=*) (samaccountname=*) (!(extensionAttribute15=*)))";
-
-
search.PropertiesToLoad.Add("samaccountname");
-
search.PropertiesToLoad.Add("mail");
-
search.PropertiesToLoad.Add("name");
-
search.PropertiesToLoad.Add("sn");
-
-
search.Sort.PropertyName = "sn";
-
-
string pieces;
-
string name = "";
-
-
foreach (SearchResult result in search.FindAll())
-
{
-
-
pieces = result.Properties["samaccountname"][0].ToString().Split(new Char[] { '\'' });
-
for (int i = 0; i < pieces.GetLength(0); i++)
-
{
-
name = name + pieces[i];
-
}
-
-
manager.Items.Add(new ListItem(name, result.Properties["samaccountname"][0].ToString()));
-
-
name = "";
-
-
}
-
-
entry.Close();
-
}
Trust me before the fanatics see the amount of bad this isn't mine and I am dedicating learning and redoing all of this code and AD paths and what not. With that being said that is the code and how it is displayed as of right now and as of when it worked for as much as I know.
Ok, this line:
should be change to
Since pieces is going to receive an array of strings from that split(). I believe that is what one of the error messages you are getting. Actually I think it will clear up both of them, since pieces will then be a string[], it will also contain the .GetLength() function.
HOWEVER, based on the apparent logic in that function, I would change .GetLength() to .Length anyway.
As GetLength(0) will return the number of characters in the first string contained in the pieces array, and not how many elements are in the array.
Stack trace says
; expected
I don't think I am missing a ; anywhere that I wasn't before.
If you were missing a in CODE code, doing abuild would throw up an error message in visual studio.
However, if you were missing a ; in some kind of query string or something, that might be harder to find.
Error messages should give you a line number?
Line 111 - for (int i = 0; i < pieces.Length(0); i++)
which is also giving me a Method name expected error.
Ahh, oopsy. I should have told you that Length is a property, not a function. It does not require any arguments.
I am trying to figure out what that bit of code is doing.
It looks like it's taking this:
"something/someotherthing/somename"
and making it be
"somethingsomeotherthingsomename".
Seems like a lot of work that could have been handled with the .Replace() function.
Ahh, oopsy. I should have told you that Length is a property, not a function. It does not require any arguments.
I am trying to figure out what that bit of code is doing.
It looks like it's taking this:
"something/someotherthing/somename"
and making it be
"somethingsomeotherthingsomename".
Seems like a lot of work that could have been handled with the .Replace() function.
I got it working again and I have no idea how... I just did pieces. and GetLength was there... Now is there a way to do this without having to change a ton of things around like this code is doing.
I got it working again and I have no idea how... I just did pieces. and GetLength was there... Now is there a way to do this without having to change a ton of things around like this code is doing.
-
string[] pieces;
-
string name = "";
-
-
foreach (SearchResult result in search.FindAll())
-
{
-
name = result.Properties["samaccountname"][0].ToString().Replace("\","");
-
manager.Items.Add(new ListItem(name, result.Properties["samaccountname"][0].ToString()));
-
}
-
That is assuming you were splitting on the \ character.
What about VB.net. Would this little aray be easier to make or am I barking up the wrong tree. I am new to AD for the most part and can't get a web server to display AD stuff in a dropdownlist. But this project after it broke exhibited the same behavior as the project I was working on and was stuck on.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Nico |
last post by:
Hello folks,
I am currently storing a set of objects inside an array,
$itemlist = array();
$itemlist = new item("myitem");
//...
and I am looking to develop a search function, which...
|
by: buda |
last post by:
Hi,
I've been wondering for a while now (and always forgot to ask :) what is the
exact quote from the Standard that forbids the use of (&array)
(when x >= number_of_columns) as stated in the FAQ...
|
by: shmartonak |
last post by:
For maximum portability what should the type of an array index be? Can
any integer type be used safely? Or should I only use an unsigned type?
Or what?
If I'm using pointers to access array...
|
by: Peter |
last post by:
I run into this situation all the time and I'm wondering what is the
most efficient way to handle this issue:
I'll be pulling data out of a data source and want to load the data
into an array so...
|
by: yeti349 |
last post by:
Hi, I'm using the following code to retrieve data from an xml file and
populate a javascript array. The data is then displayed in html table
form. I would like to then be able to sort by each...
|
by: Shhnwz.a |
last post by:
Hi,
I am in confusion regarding jargons.
When it is technically correct to say.. String or Character Array.in c.
just give me your perspectives in this issue.
Thanx in Advance.
|
by: Peter Olcott |
last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a
I think that the operator() member function does not work correctly, does
anyone else know how to make a template for making two...
|
by: Zytan |
last post by:
I want to make a zero element array. I know that Nothing is not the
same as a zero element array, since I can't get the length of, or
iterate through, an array = Nothing. I could make a zero...
|
by: =?Utf-8?B?U2hhcm9u?= |
last post by:
Hi Gurus,
I need to transfer a jagged array of byte by reference to unmanaged
function, The unmanaged code should changed the values of the array, and when
the unmanaged function returns I need...
|
by: ctj951 |
last post by:
I have a very specific question about a language issue that I was
hoping to get an answer to. If you allocate a structure that
contains
an array as a local variable inside a function and return...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |