Just an idea.
I have for a long time struggled to validate logon against an active directory.
Tried to understand and implement LDAP protocol. Read the article at Clarion Mag, but without success.
Then I got an idea. Why not just try to map a drive to a share. No need to manage password and users. Everyone who has access to share now has access to my NetTalk server.
Here's the code I used: (taken from an earlier post on public.Clarion6 NG from someone called Alex - thanks Alex)
Prototypes:
MODULE('WinAPI')
WNetAddConnection2(*NETRESOURCE,LONG,LONG,ULONG),SIGNED,PASCAL,RAW,NAME('WNetAddConnection2A')
WNetCancelConnection2A(*CSTRING,ULONG,SIGNED),SIGNED,PASCAL,RAW
WNetGetConnection(*CSTRING,*CSTRING,*SIGNED),SIGNED,PASCAL,RAW
GetLastError(),ULONG,PASCAL
END
Equates and types:
NETRESOURCE GROUP,TYPE
dwScope ULONG
dwType ULONG
dwDisplayType ULONG
dwUsage ULONG
lpLocalName LONG
lpRemoteName LONG
lpComment LONG
lpProvider LONG
END
ERROR_ACCESS_DENIED EQUATE(5)
ERROR_ALREADY_ASSIGNED EQUATE(85)
ERROR_BAD_DEV_TYPE EQUATE(66)
ERROR_BAD_DEVICE EQUATE(1200)
ERROR_BAD_NET_NAME EQUATE(67)
ERROR_BAD_PROFILE EQUATE(1206)
ERROR_CANNOT_OPEN_PROFILE EQUATE(1205)
ERROR_DEVICE_ALREADY_REMEMBERED EQUATE(1202)
ERROR_NO_NET_OR_BAD_PATH EQUATE(1203)
ERROR_NO_NETWORK EQUATE(1222)
ERROR_DEVICE_IN_USE EQUATE(2404)
ERROR_NOT_CONNECTED EQUATE(2250)
ERROR_OPEN_FILES EQUATE(2401)
Required data:
LocalPath CSTRING(100)
NetworkPath CSTRING(100)
NetworkProvider CSTRING(100)
NetPassword CSTRING(100)
NetUser CSTRING(100)
NetFlags ULONG
NetRes GROUP(NETRESOURCE)
END
Adding connection:
LocalPath = 'H:'
NetworkPath = '\\myserver\drive-c'
NetworkProvider = ''
NetRes.dwType = 1
NetRes.lpLocalName = ADDRESS(LocalPath)
NetRes.lpRemoteName = ADDRESS(NetworkPath)
NetRes.lpProvider = ADDRESS(NetworkProvider)
NetPassword = ''
NetUser = ''
NetFlags = 08h
IF WNetAddConnection2(NetRes,0,0,NetFlags) <> 0
ret# = GetLastError()
CASE ret#
OF ERROR_ACCESS_DENIED
OF ERROR_ALREADY_ASSIGNED
OF ERROR_BAD_DEV_TYPE
OF ERROR_BAD_DEVICE
OF ERROR_BAD_NET_NAME
OF ERROR_BAD_PROFILE
OF ERROR_CANNOT_OPEN_PROFILE
OF ERROR_DEVICE_ALREADY_REMEMBERED
OF ERROR_NO_NET_OR_BAD_PATH
OF ERROR_NO_NETWORK
ELSE
END
END
Removing connection:
Flag = 0
IF WNetCancelConnection2A(LocalPath,0,Flag) <> 0
CASE GetLastError()
OF ERROR_BAD_PROFILE
OF ERROR_CANNOT_OPEN_PROFILE
OF ERROR_DEVICE_IN_USE
OF ERROR_NOT_CONNECTED
OF ERROR_OPEN_FILES
END
END