Hi,
Maybe this subject has come up before but here it goes.
Im using c# in asp.net and im connecting to ldap server to retrieve some
properties from it, some properties work ok but for others i get the error
mentioned in the subject line, im using DirectoryService and here is the
code.
I add 3 properties, cn wich is not multi value, mail wich is and objectClass
is multi also, objectClass is the one that generates the error(when i take
the try catch out).
**Code Start**
DirectorySearcher searcher = new DirectorySearcher();
searcher.SearchRoot = new DirectoryEntry(LDAP://someserver/cn=somewhere);
searcher.SearchScope = SearchScope.Subtree;
searcher.Filter = "(uid=some)";
searcher.PropertiesToLoad.Add("cn");
searcher.PropertiesToLoad.Add("mail");
searcher.PropertiesToLoad.Add("objectClass");
SearchResultCollection results = searcher.FindAll();
foreach(SearchResult result in results)
{
Response.Write("mail=" + result.Properties["mail"][0] + "<br>");
if (result.Properties["mail"].Count > 1)
{
for (int i = 0;i < result.Properties["mail"].Count;i++)
{
Response.Write("mail=" + result.Properties["mail"][i] + "<br>");
}
}
else
{
Response.Write("mail=" + result.Properties["mail"][0] + "<br>");
}
try
{
if (result.Properties["objectClass"].Count > 1)
{
for (int i = 0;i < result.Properties["objectClass"].Count;i++)
{
Response.Write("objectClass=" +
result.Properties["objectClass"][i].ToString() + "<br>");
}
}
else
{
Response.Write("objectClass=" +
result.Properties["objectClass"][0].ToString() + "<br>");
}
}
catch
{
Response.Write("Couldnt write objectClass Property<br>");
}
}
**Code End**
Any help appreciated.
Best Regards
Agust 2 1769
Hi,
Ive tried a few things but cant seem to get it to work yet, im not connecting to AD but "3rd party" ldap server
I get the same error when i use winform instead of asp, i have managed to write out objectClass with vb script using getinfoex but it would be best if i could use .net and directoryservices
I know im connected to the ldap server cause if i change the pw i get an error and also im able to write out some properties and not others
Im totally lost, if anyone has any idea it would be appreciated
Best Regard
Ãgúst Kristinn Arnlaugsso
----- Ãgúst Kristinn Arnlaugsson wrote: ----
Hi
Maybe this subject has come up before but here it goes
Im using c# in asp.net and im connecting to ldap server to retrieve som
properties from it, some properties work ok but for others i get the erro
mentioned in the subject line, im using DirectoryService and here is th
code
I add 3 properties, cn wich is not multi value, mail wich is and objectClas
is multi also, objectClass is the one that generates the error(when i tak
the try catch out)
**Code Start*
DirectorySearcher searcher = new DirectorySearcher()
searcher.SearchRoot = new DirectoryEntry(LDAP://someserver/cn=somewhere)
searcher.SearchScope = SearchScope.Subtree
searcher.Filter = "(uid=some)"
searcher.PropertiesToLoad.Add("cn")
searcher.PropertiesToLoad.Add("mail")
searcher.PropertiesToLoad.Add("objectClass")
SearchResultCollection results = searcher.FindAll()
foreach(SearchResult result in results
Response.Write("mail=" + result.Properties["mail"][0] + "<br>")
if (result.Properties["mail"].Count > 1
for (int i = 0;i < result.Properties["mail"].Count;i++
Response.Write("mail=" + result.Properties["mail"][i] + "<br>")
els
Response.Write("mail=" + result.Properties["mail"][0] + "<br>")
tr
if (result.Properties["objectClass"].Count > 1
for (int i = 0;i < result.Properties["objectClass"].Count;i++
Response.Write("objectClass="
result.Properties["objectClass"][i].ToString() + "<br>")
els
Response.Write("objectClass="
result.Properties["objectClass"][0].ToString() + "<br>")
catc
Response.Write("Couldnt write objectClass Property<br>")
**Code End*
Any help appreciated
Best Regard
Agus
What directory server are you talking to, what version of LDAP does it
supports?
Did you try first using the adsedit tool?
Willy.
"Ágúst Kristinn Arnlaugsson" <ag******@xxxxxxx.simnet.is> wrote in message
news:87**********************************@microsof t.com... Hi,
Ive tried a few things but cant seem to get it to work yet, im not connecting to AD but "3rd party" ldap server. I get the same error when i use winform instead of asp, i have managed to write out objectClass with vb script using getinfoex but it would be best if i could use .net and directoryservices.
I know im connected to the ldap server cause if i change the pw i get an error and also im able to write out some properties and not others.
Im totally lost, if anyone has any idea it would be appreciated.
Best Regards Ágúst Kristinn Arnlaugsson
----- Ágúst Kristinn Arnlaugsson wrote: -----
Hi,
Maybe this subject has come up before but here it goes.
Im using c# in asp.net and im connecting to ldap server to retrieve some properties from it, some properties work ok but for others i get the error mentioned in the subject line, im using DirectoryService and here is the code. I add 3 properties, cn wich is not multi value, mail wich is and objectClass is multi also, objectClass is the one that generates the error(when i take the try catch out).
**Code Start** DirectorySearcher searcher = new DirectorySearcher();
searcher.SearchRoot = new DirectoryEntry(LDAP://someserver/cn=somewhere);
searcher.SearchScope = SearchScope.Subtree;
searcher.Filter = "(uid=some)";
searcher.PropertiesToLoad.Add("cn"); searcher.PropertiesToLoad.Add("mail"); searcher.PropertiesToLoad.Add("objectClass");
SearchResultCollection results = searcher.FindAll();
foreach(SearchResult result in results) { Response.Write("mail=" + result.Properties["mail"][0] + "<br>");
if (result.Properties["mail"].Count > 1) { for (int i = 0;i < result.Properties["mail"].Count;i++) { Response.Write("mail=" + result.Properties["mail"][i] + "<br>"); } } else { Response.Write("mail=" + result.Properties["mail"][0] + "<br>"); }
try { if (result.Properties["objectClass"].Count > 1) { for (int i = 0;i < result.Properties["objectClass"].Count;i++) { Response.Write("objectClass=" + result.Properties["objectClass"][i].ToString() + "<br>"); } } else { Response.Write("objectClass=" + result.Properties["objectClass"][0].ToString() + "<br>"); } } catch { Response.Write("Couldnt write objectClass Property<br>"); } }
**Code End** Any help appreciated.
Best Regards Agust This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Ken in Melbourne Australia |
last post by:
For some Open Source (GPL licensed) programs that I am
working on, I am trying to create some PHP routines for data
handling with good security.
The routines I have created for this are given...
|
by: Brian Idzik |
last post by:
I've successfully setup a xhtml 1.0 strict page with Mozilla & Netscape
to display links in a toolbar into an internal <div id='content'> within
the same document. The toolbar uses some...
|
by: Java Böy |
last post by:
could some body help me what's happening here...
thanks..
char sc =
"\x31\xc0" /* xor %eax, %eax */
"\x50" /* push %eax */...
|
by: m96 |
last post by:
hi,
i'm trying to make a query to a ldap server (version v2 or v3 doen't
matter) with c#. the query works just fine but the problem is that i can't
read the custom attributes/fields, since .net...
|
by: hn |
last post by:
hi!
when querying ad (win2k) i keep getting the error "Handling of this
ADSVALUE type is not yet implemented (type = 0xb)."
but the funny thing is that i only get in with certain properties...
|
by: michaeltorus |
last post by:
Hi
I'm currently designing a new web application in .Net. I've pretty covered everything, apart from error handling.
There seems to be a few different way to do this, but something I've read...
|
by: Zorro |
last post by:
The simplicity of stack unraveling of C++ is not without defective
consequences. The following article points to C++ examples showing the
defects. An engineer aware of defects can avoid...
|
by: Adam Olsen |
last post by:
As was seen in another thread, there's a great deal of confusion
with regard to surrogates. Most programmers assume Python's unicode
type exposes only complete characters. Even CPython's own...
|
by: George2 |
last post by:
Hello everyone,
Such code segment is used to check whether function call or exception-
handling mechanism runs out of memory first (written by Bjarne),
void perverted()
{
try{
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |