FoxPro Programming
Controlling Active Directory with VFP?
Gravatar is a globally recognized avatar based on your email address. Controlling Active Directory with VFP?
  Alejandro A Sosa
  All
  Sep 30, 2015 @ 12:24pm
We want to host a VFP app on the cloud and provide access with RDS (formerly Terminal Services) and RemoteApp.

It was suggested by Azure folks that we create a virtual LAN with RemoteApp users accessing files on a server.

Besides the cost and performance issues that Rick brought up, this adds the issue of how to manage ActiveDirectory users programmatically.

We are not very savvy in .NET and would prefer to do it from VFP. Anybody knows what options exist?

TIA,

Alex

Gravatar is a globally recognized avatar based on your email address. Re: Controlling Active Directory with VFP?
  Rick Strahl
  Alejandro A Sosa
  Sep 30, 2015 @ 07:57pm

You can program ActiveDirectory via DirectoryServices and COM from FoxPro. I have some code posted somewhere. Look for ADSI and ActiveDirectory. Been a long time and it's a pain in the ass because you have to do extensive error checking.

It might actually be easier to do this with .NET and wwDotnetBridge as the .NET apis are more fault tolerant and make capturing errors easier.

+++ Rick ---



We want to host a VFP app on the cloud and provide access with RDS (formerly Terminal Services) and RemoteApp.

It was suggested by Azure folks that we create a virtual LAN with RemoteApp users accessing files on a server.

Besides the cost and performance issues that Rick brought up, this adds the issue of how to manage ActiveDirectory users programmatically.

We are not very savvy in .NET and would prefer to do it from VFP. Anybody knows what options exist?

TIA,

Alex




Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: Controlling Active Directory with VFP?
  Alejandro A Sosa
  Rick Strahl
  Sep 30, 2015 @ 10:20pm
Thanks Rick.

Doing it with .NET and wwDotnetBridge sounds good, but assumes there is a .NET application to do the job which we control using wwDotNetBridge. Do you know of an application I could use for this purpose?

Alex

You can program ActiveDirectory via DirectoryServices and COM from FoxPro. I have some code posted somewhere. Look for ADSI and ActiveDirectory. Been a long time and it's a pain in the ass because you have to do extensive error checking.

It might actually be easier to do this with .NET and wwDotnetBridge as the .NET apis are more fault tolerant and make capturing errors easier.

+++ Rick ---



We want to host a VFP app on the cloud and provide access with RDS (formerly Terminal Services) and RemoteApp.

It was suggested by Azure folks that we create a virtual LAN with RemoteApp users accessing files on a server.

Besides the cost and performance issues that Rick brought up, this adds the issue of how to manage ActiveDirectory users programmatically.

We are not very savvy in .NET and would prefer to do it from VFP. Anybody knows what options exist?

TIA,

Alex




Gravatar is a globally recognized avatar based on your email address. Re: Controlling Active Directory with VFP?
  Rick Strahl
  Alejandro A Sosa
  Oct 1, 2015 @ 06:38am

In Web Connection there's a WebServer.vcx class that includes a ActiveDirectory class that you can use to do most of this actually. It doesn't use .NET - just uses the ADSI directory services directly. Somewhere I've posted some code to do user administration with this stuff but I can't find it. If you do some searching here on the message board or on the UT you might run into it.

Either way managing the AD using these antiquated interfaces is a pain - the .NET stuff is a little easier but if you use wwDotnetBridge it'll also be messy. In .NET the access for this lives in DirectoryServices.

+++ Rick ---



Thanks Rick.

Doing it with .NET and wwDotnetBridge sounds good, but assumes there is a .NET application to do the job which we control using wwDotNetBridge. Do you know of an application I could use for this purpose?

Alex

You can program ActiveDirectory via DirectoryServices and COM from FoxPro. I have some code posted somewhere. Look for ADSI and ActiveDirectory. Been a long time and it's a pain in the ass because you have to do extensive error checking.

It might actually be easier to do this with .NET and wwDotnetBridge as the .NET apis are more fault tolerant and make capturing errors easier.

+++ Rick ---



We want to host a VFP app on the cloud and provide access with RDS (formerly Terminal Services) and RemoteApp.

It was suggested by Azure folks that we create a virtual LAN with RemoteApp users accessing files on a server.

Besides the cost and performance issues that Rick brought up, this adds the issue of how to manage ActiveDirectory users programmatically.

We are not very savvy in .NET and would prefer to do it from VFP. Anybody knows what options exist?

TIA,

Alex







Rick Strahl
West Wind Technologies

Making waves on the Web
from Maui

Gravatar is a globally recognized avatar based on your email address. Re: Controlling Active Directory with VFP?
  Alejandro A Sosa
  Rick Strahl
  Oct 1, 2015 @ 07:04am
Thank you very much. Big help.

In Web Connection there's a WebServer.vcx class that includes a ActiveDirectory class that you can use to do most of this actually. It doesn't use .NET - just uses the ADSI directory services directly. Somewhere I've posted some code to do user administration with this stuff but I can't find it. If you do some searching here on the message board or on the UT you might run into it.

Either way managing the AD using these antiquated interfaces is a pain - the .NET stuff is a little easier but if you use wwDotnetBridge it'll also be messy. In .NET the access for this lives in DirectoryServices.

+++ Rick ---



Thanks Rick.

Doing it with .NET and wwDotnetBridge sounds good, but assumes there is a .NET application to do the job which we control using wwDotNetBridge. Do you know of an application I could use for this purpose?

Alex

You can program ActiveDirectory via DirectoryServices and COM from FoxPro. I have some code posted somewhere. Look for ADSI and ActiveDirectory. Been a long time and it's a pain in the ass because you have to do extensive error checking.

It might actually be easier to do this with .NET and wwDotnetBridge as the .NET apis are more fault tolerant and make capturing errors easier.

+++ Rick ---



We want to host a VFP app on the cloud and provide access with RDS (formerly Terminal Services) and RemoteApp.

It was suggested by Azure folks that we create a virtual LAN with RemoteApp users accessing files on a server.

Besides the cost and performance issues that Rick brought up, this adds the issue of how to manage ActiveDirectory users programmatically.

We are not very savvy in .NET and would prefer to do it from VFP. Anybody knows what options exist?

TIA,

Alex







Gravatar is a globally recognized avatar based on your email address. Re: Controlling Active Directory with VFP?
  n/a
  Alejandro A Sosa
  Oct 2, 2015 @ 01:41am

We want to host a VFP app on the cloud and provide access with RDS (formerly Terminal Services) and RemoteApp.

It was suggested by Azure folks that we create a virtual LAN with RemoteApp users accessing files on a server.

Besides the cost and performance issues that Rick brought up, this adds the issue of how to manage ActiveDirectory users programmatically.


Here is some code that I use to check if the user is a member of "Labraintranet" group:
Local lcNTUserName, lcUserDomain, lcUserName, loNetwork, ccADS_NAME_INITTYPE_GC, ccADS_NAME_TYPE_NT4
Local ccADS_NAME_TYPE_1779, lcDN, loNameTrans, lNoAd

ccADS_NAME_INITTYPE_GC = 3
ccADS_NAME_TYPE_NT4 = 3
ccADS_NAME_TYPE_1779 = 1
lNoAd = .F.

Odse = Getobject("LDAP://RootDse")
loNetwork = Createobject("WScript.Network")

lcUserDomain = loNetwork.UserDomain
loNameTrans = Createobject("NameTranslate")
If Vartype(loNameTrans) <> "O"
lNoAd = .T.
Endif
* un = Users login name
Try
loNameTrans.Init( ccADS_NAME_INITTYPE_GC, "")
loNameTrans.Set(ccADS_NAME_TYPE_NT4, lcUserDomain + "\" + un)
lcDN = loNameTrans.Get(ccADS_NAME_TYPE_1779)
loAdUser = Getobject("LDAP://" + lcDN)
Catch To oException
ENDTRY
If Vartype(oException) = "O"
RETURN .f.
ENDIF
oException = null
Y=0
Do While .T.
Try
cMemberOf = loAdUser.Getex("memberOf")
If Not Empty(cMemberOf[1])
Exit
Endif
Catch To oException
Endtry
If Vartype(oException) = "O"
If oException.ErrorNo <> 0
This.seterror("AD not available")
Strtofile("Error occurred at: " + Transform(Datetime()) + CRLF +;
[ Error: ] + Str(oException.ErrorNo) + CRLF +;
[ LineNo: ] + Str(oException.Lineno) + CRLF +;
[ Message: ] + oException.Message + CRLF +;
[ Procedure: ] + oException.Procedure + CRLF +;
[ Details: ] + oException.Details + CRLF +;
[ RetryCount: ] + Str(Y) + CRLF +;
[ LineContents: ] + oException.LineContents + CRLF ;
, This.cappstartpath + "Errors.log",.T.)
lNoAd = .T.
Endif
Endif
Y=Y+1
If Y > 20
Exit
Endif
Enddo

If lNoAd
Return .F.
Endif

Local isMember
isMember = .F.
For Each odata In cMemberOf
If "Labraintranet"$odata
isMember = .T.
Exit
Endif
Endfor

If isMember


Do something...

--
JS
Gravatar is a globally recognized avatar based on your email address. Re: Controlling Active Directory with VFP?
  Alejandro A Sosa
  Jukka Salminen
  Oct 6, 2015 @ 06:08am
Thank you very much Jukka! Will check it out.

Alex



We want to host a VFP app on the cloud and provide access with RDS (formerly Terminal Services) and RemoteApp.

It was suggested by Azure folks that we create a virtual LAN with RemoteApp users accessing files on a server.

Besides the cost and performance issues that Rick brought up, this adds the issue of how to manage ActiveDirectory users programmatically.


Here is some code that I use to check if the user is a member of "Labraintranet" group:
Local lcNTUserName, lcUserDomain, lcUserName, loNetwork, ccADS_NAME_INITTYPE_GC, ccADS_NAME_TYPE_NT4
Local ccADS_NAME_TYPE_1779, lcDN, loNameTrans, lNoAd

ccADS_NAME_INITTYPE_GC = 3
ccADS_NAME_TYPE_NT4 = 3
ccADS_NAME_TYPE_1779 = 1
lNoAd = .F.

Odse = Getobject("LDAP://RootDse")
loNetwork = Createobject("WScript.Network")

lcUserDomain = loNetwork.UserDomain
loNameTrans = Createobject("NameTranslate")
If Vartype(loNameTrans) <> "O"
lNoAd = .T.
Endif
* un = Users login name
Try
loNameTrans.Init( ccADS_NAME_INITTYPE_GC, "")
loNameTrans.Set(ccADS_NAME_TYPE_NT4, lcUserDomain + "\" + un)
lcDN = loNameTrans.Get(ccADS_NAME_TYPE_1779)
loAdUser = Getobject("LDAP://" + lcDN)
Catch To oException
ENDTRY
If Vartype(oException) = "O"
RETURN .f.
ENDIF
oException = null
Y=0
Do While .T.
Try
cMemberOf = loAdUser.Getex("memberOf")
If Not Empty(cMemberOf[1])
Exit
Endif
Catch To oException
Endtry
If Vartype(oException) = "O"
If oException.ErrorNo <> 0
This.seterror("AD not available")
Strtofile("Error occurred at: " + Transform(Datetime()) + CRLF +;
[ Error: ] + Str(oException.ErrorNo) + CRLF +;
[ LineNo: ] + Str(oException.Lineno) + CRLF +;
[ Message: ] + oException.Message + CRLF +;
[ Procedure: ] + oException.Procedure + CRLF +;
[ Details: ] + oException.Details + CRLF +;
[ RetryCount: ] + Str(Y) + CRLF +;
[ LineContents: ] + oException.LineContents + CRLF ;
, This.cappstartpath + "Errors.log",.T.)
lNoAd = .T.
Endif
Endif
Y=Y+1
If Y > 20
Exit
Endif
Enddo

If lNoAd
Return .F.
Endif

Local isMember
isMember = .F.
For Each odata In cMemberOf
If "Labraintranet"$odata
isMember = .T.
Exit
Endif
Endfor

If isMember


Do something...

© 1996-2024