CanAFunk
Posts: 4
|
Posted: 04/12/2013, 10:18 AM |
|
Hi I am trying to add "Imports System.DirectoryServices" as a reference.
If I go to Project Setting under Server/Scripts the Reference option is Grayed Out,
How do I add System.DirectoryServices to my project.
Imports System.DirectoryServices
is not working
|
 |
 |
cvboucher
Posts: 191
|
Posted: 04/12/2013, 7:31 PM |
|
For a CCS4 ASP.Net InMotion VB Project I put the following in the Assemblies project setting.
System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A
Craig
|
 |
 |
CanAFunk
Posts: 4
|
Posted: 04/15/2013, 6:59 AM |
|
Hi thanks for the reply, my project is set on vb.Net and not "in Motion"
But I have added the code to the Assemblies project setting and still get an error.
Does your solution only apply to vb.Net in Motion?
|
 |
 |
cvboucher
Posts: 191
|
Posted: 04/15/2013, 5:41 PM |
|
Should apply to either. I'm not sure what will happen if the .Net Framework version of the project doesn't match the Version in the Assemblies project setting. Also, depending on how you are referencing the classes you may still need to Import System.DirectoryServices into your code. Here is a bit of code I use to authenticate against AD.
Dim ErrorFlag As Boolean = False
Dim entry As New System.DirectoryServices.DirectoryEntry("LDAP://YourADServer.com/dc=YourADServer,dc=com", Login.GetControl(Of MTTextBox)("login").Text, Login.GetControl(Of MTTextBox)("password").Text, System.DirectoryServices.AuthenticationTypes.Secure)
Try
entry.RefreshCache()
Catch ex As Exception
Login.Errors.Add(InMotion.Common.Resources.ResManager.GetString("CCS_LoginError"))
ErrorFlag = True
Finally
entry.Dispose()
End Try
I specified the whole System.DirectoryServices namespace in my code so I didn't need to Import it. With this code you would need to change how you get at the userid and password (and the AD Server) since this is from an InMotion project.
HTH,
Craig
|
 |
 |
CanAFunk
Posts: 4
|
Posted: 04/15/2013, 9:02 PM |
|
Thanks for the response, have a look at this, If i use the following :
Line 56: Dim oRoot As DirectoryEntry = New System.DirectoryServices.DirectoryEntry("LDAP://za.xxx.inter/ou=People,dc=za,dc=xxx,dc=inter")
I get this error:
Compiler Error Message: BC30002: Type 'DirectoryEntry' is not defined.
Project settings
|
 |
 |
cvboucher
Posts: 191
|
Posted: 04/16/2013, 2:51 PM |
|
If you don't put Imports System.DirectoryServices at the top of your code file then Dim oRoot As DirectoryEntry needs to be Dim oRoot As System.DirectoryServices.DirectoryEntry
Craig
|
 |
 |
CanAFunk
Posts: 4
|
Posted: 04/16/2013, 3:06 PM |
|
THANKS, Adding it to web.cofig file also did the trick
<add assembly="System.DirectoryServices,Version=1.0.3300.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a" />
|
 |
 |
|