Hi Guys
First of all i want to say hi to everyone. I'm making a simple Active Directory application that you can add and remove users but when i try to run it in a webpage the server raises a message saying "The specified domain either does not exist or could not be contacted". I have about 1 week trying to figure out why is doing that. I tried to run the same example code in a windows application form but work's fine. But when i tried to write an ASP.NET error i receive this connection error (i guess is maybe the protocol LDAP that get's the error but i don't know why). can somebody please help me??. I write an Visual Basic NET Active directory example to check this error. In Windows Forms and vbscript Works fine. In ASP.NET doesn't
Imports System.DirectoryServices
Dim a As New DirectoryEntry("LDAP://CN=Testfolder,OU=Users,OU=General,DC=my,DC=domain,DC=com")
Dim b As New DirectoryEntry("LDAP://CN=Phoenixzero,OU=Administrators,OU=Users,OU=Sys,OU=Sys,DC=my,DC=domain,DC=com")
Dim isMember As Boolean = Convert.ToBoolean(a.Invoke("IsMember", New Object() {b.Path}))
If isMember Then
MsgBox("User " & b.Properties("cn").Value & " is already a member of the group")
'
' Remove the user from the group by invoking the remove method
'
a.Invoke("Remove", New Object() {b.Path})
Else
'
' Add the user to the group by invoking the Add method
'
a.Invoke("Add", New Object() {b.Path})
MsgBox("User added")
End If
'
' Cleanup our allocated objects
'
If Not IsNothing(b) Then
b.Dispose()
End If
If Not IsNothing(a) Then
a.Dispose()
End If
Like i say, this code works in visual Basic .NET Windows Forms and VBScript, but doesn't work in ASP.NET webpages. I need it in webpage because is an extension of a website that i'm creating
Best regards
ZeldaDX
by: ihenryPosted on 2006-08-24 at 09:34:12ID: 17383059
The problem could be as simple as lack of permission to access the domain. Depending on IIS security settings, a web application typically runs anonymously. Here I assume that your webpage is running under aspnet user or network service user (or IUSER_MACHINE, if you enable impersonation). This account has very limited access to external resources. It's also possible your IIS server used different authentication method, e.g. basic or iwa. In either case, the user account of which your web application is running under does not have enough permissions to access the active directory server.
Now, how to deal with this error. Well, first I need to make sure that my guess above is right. Try to hard code a user name and password. If the error dissapears, please check back here cause I'll have more suggestion to make.
<off topic>
Come to think of it, active directory was my favorite topic and it's been a while since my last post in this forum :o)
</off topic>