|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
LDAP Error:The directory service is not availableHi
I have a problem with LDAP, I use apache directory server and I would add a new user ....I use Visual Studio and the code is: public static void prova(string FullName) { DirectoryEntry container; DirectoryEntries ChildEntry; container = new DirectoryEntry("LDAP://localhost:10389/cn=user1,ou=users,ou=system", "admin", "secret"); try { ChildEntry = container.Children; DirectoryEntry NewEntry = ChildEntry.Add("cn=" + FullName, "user"); NewEntry.CommitChanges(); NewEntry.Close(); } catch (Exception ex) { throw new Exception("Error " + ex.Message); } } The problem is that I have this type of error:The directory service is not available somebody could help me? |
|
|
Re: LDAP Error:The directory service is not availableHi,
I believe you need to use the full DN of the user in your DirectoryEntry creation. Maybe the following code would work better... DirectoryEntry("LDAP://localhost:10389/cn=user1,ou=users,ou=system", "uid=admin,ou=system", "secret");
Hope this helps,
Pierre-Arnaud On Mon, Oct 26, 2009 at 12:10 PM, pepe_gaetano <pepe_gaetano@...> wrote:
|
|
|
Re: LDAP Error:The directory service is not availableI tried with "uid = admin, ou = system" but I have always the same error
|
|
|
Re: LDAP Error:The directory service is not availableHi,
And you are sure that ApacheDS runs on your machine on port 10389? Could you try to get a more details error message? Could you find out which line of your code causes the error? A last advice is to use capture the network traffic, for example using Wireshark (but afaik it is not possible to capture the localhost interface on Windows). Kind Regards, Stefan pepe_gaetano schrieb: > Hi > > I have a problem with LDAP, I use apache directory server and I would add a > new user ....I use Visual Studio and the code > > is: > > public static void prova(string FullName) > { > DirectoryEntry container; > DirectoryEntries ChildEntry; > > container = new > DirectoryEntry("LDAP://localhost:10389/cn=user1,ou=users,ou=system", > "admin", "secret"); > > try > { > > ChildEntry = container.Children; > DirectoryEntry NewEntry = ChildEntry.Add("cn=" + FullName, > "user"); > NewEntry.CommitChanges(); > NewEntry.Close(); > } > catch (Exception ex) > { > throw new Exception("Error " + ex.Message); > } > } > > The problem is that I have this type of error:The directory service is not > available > somebody could help me? |
|
|
Re: LDAP Error:The directory service is not availablethe server and port I think they work because I checked using Apache Studio! the error is here
newentry = ChildEntry.Add DirectoryEntry ( "cn =" + FullName, "user"); |
|
|
Re: LDAP Error:The directory service is not availableHi,
pepe_gaetano wrote: > Hi > > I have a problem with LDAP, I use apache directory server and I would add a > new user ....I use Visual Studio and the code > > is: > > public static void prova(string FullName) > { > DirectoryEntry container; > DirectoryEntries ChildEntry; > > container = new > DirectoryEntry("LDAP://localhost:10389/cn=user1,ou=users,ou=system", > "admin", "secret"); Is "cn=user1, ou=users,ou=system" really your container or do you want to add new entries to "ou=users,ou=system"? To do a simple bind you need to use a bind DN and specify the right authentication type (AuthenticationTypes.None). I'm not sure if other authentication types work with non-AD servers. > try > { > > ChildEntry = container.Children; > DirectoryEntry NewEntry = ChildEntry.Add("cn=" + FullName, > "user"); Apache Directory Server doesn't contain the "user" object class. So if you haven't added it to the schema you should use another object class (e.g. inetOrgPerson) Before you commit the changes you need to add all the other mandatory attributes (cn and sn for inetOrgPerson). > NewEntry.CommitChanges(); > NewEntry.Close(); > } > catch (Exception ex) > { > throw new Exception("Error " + ex.Message); > } > } Here is your modified code that works for me: try { DirectoryEntry Container = new DirectoryEntry( "LDAP://192.168.2.101:10389/ou=users,ou=system", "uid=admin,ou=system", "secret", AuthenticationTypes.None); DirectoryEntries ChildEntries = Container.Children; DirectoryEntry NewEntry = ChildEntries.Add( "cn=" + FullName, "inetOrgPerson"); NewEntry.Properties["cn"].Add(FullName); NewEntry.Properties["sn"].Add(FullName); NewEntry.CommitChanges(); NewEntry.Close(); } catch (Exception ex) { Console.Out.WriteLine(ex.Message); Console.Out.WriteLine(ex.StackTrace); } BTW: There is a much better C# LDAP API from Novell, see [1][2]. There are also many examples available. Kind Regards, Stefan [1] http://forge.novell.com/modules/xfcontent/downloads.php/ldapcsharp [2] http://www.novell.com/coolsolutions/feature/11204.html |
|
|
Re: LDAP Error:The directory service is not availableHi
thanks a lot ... it works I ask you a question? and if I want to add a group what should I use? no "inetOrgPerson" but what?
|
|
|
Re: LDAP Error:The directory service is not availableHi Pepe,
use groupOfNames or groupOfUniqueNames. I'd kindly recommend to study some LDAP book first in order to learn the LDAP basics. A nice online book is http://www.zytrax.com/books/ldap/ Kind Regards, Stefan pepe_gaetano wrote: > Hi > thanks a lot ... it works > I ask you a question? and if I want to add a group what should I use? no > "inetOrgPerson" but what? > > > > Stefan Seelmann-3 wrote: >> Hi, >> >> pepe_gaetano wrote: >>> Hi >>> >>> I have a problem with LDAP, I use apache directory server and I would add >>> a >>> new user ....I use Visual Studio and the code >>> >>> is: >>> >>> public static void prova(string FullName) >>> { >>> DirectoryEntry container; >>> DirectoryEntries ChildEntry; >>> >>> container = new >>> DirectoryEntry("LDAP://localhost:10389/cn=user1,ou=users,ou=system", >>> "admin", "secret"); >> Is "cn=user1, ou=users,ou=system" really your container or do you want >> to add new entries to "ou=users,ou=system"? >> >> To do a simple bind you need to use a bind DN and specify the right >> authentication type (AuthenticationTypes.None). I'm not sure if other >> authentication types work with non-AD servers. >> >>> try >>> { >>> >>> ChildEntry = container.Children; >>> DirectoryEntry NewEntry = ChildEntry.Add("cn=" + >>> FullName, >>> "user"); >> Apache Directory Server doesn't contain the "user" object class. So if >> you haven't added it to the schema you should use another object class >> (e.g. inetOrgPerson) >> >> Before you commit the changes you need to add all the other mandatory >> attributes (cn and sn for inetOrgPerson). >> >>> NewEntry.CommitChanges(); >>> NewEntry.Close(); >>> } >>> catch (Exception ex) >>> { >>> throw new Exception("Error " + ex.Message); >>> } >>> } >> Here is your modified code that works for me: >> >> try >> { >> DirectoryEntry Container = new DirectoryEntry( >> "LDAP://192.168.2.101:10389/ou=users,ou=system", >> "uid=admin,ou=system", "secret", AuthenticationTypes.None); >> >> DirectoryEntries ChildEntries = Container.Children; >> DirectoryEntry NewEntry = ChildEntries.Add( >> "cn=" + FullName, "inetOrgPerson"); >> NewEntry.Properties["cn"].Add(FullName); >> NewEntry.Properties["sn"].Add(FullName); >> >> NewEntry.CommitChanges(); >> NewEntry.Close(); >> } >> catch (Exception ex) >> { >> Console.Out.WriteLine(ex.Message); >> Console.Out.WriteLine(ex.StackTrace); >> } >> >> >> BTW: There is a much better C# LDAP API from Novell, see [1][2]. There >> are also many examples available. >> >> >> Kind Regards, >> Stefan >> >> >> [1] http://forge.novell.com/modules/xfcontent/downloads.php/ldapcsharp >> [2] http://www.novell.com/coolsolutions/feature/11204.html >> >> > |
| Free embeddable forum powered by Nabble | Forum Help |