Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Newobject not returning an object
Message
De
07/08/2009 10:34:19
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
Newobject not returning an object
Divers
Thread ID:
01416744
Message ID:
01416744
Vues:
284
Hello All

I am supporting a legacy app and have to occasionally set up new users from the command line in VFP.

I have always used the follwing syntax to return an instance of the object.


oAdmin = newo("localadminuser", "classes.prg")

? oAdmin.Login("markyo", "lillian")

However now oAdmin just contains a logical false instead of an object.
I am at a loss as to why this is.
Here is the class.
Many Thanks


define class localadminuser as localuser

*cCLSID = "{7655CBB6-C55F-4450-AF96-90D405C7EA1E}"
cCLSID = "aegisuser.useradmin"
cServer = ""

procedure NewUser(cNewUserName as string, nUserLevel as integer, ;
cSurname as string, cFirstName as string, dDOB as date, cTelephoneNumber as string) as Boolean

return this.oUser.NewUser(cNewUserName, nUserLevel, cSurname, cFirstName, dDOB, ;
cTelephoneNumber, this.cToken, sys(0), _vfp.hwnd, _vfp.processid, _vfp.threadid)
endproc

procedure ClearPassword(cUsername as string) as Boolean

return this.oUser.ClearPassword(cUsername, this.cToken, sys(0), _vfp.hwnd, _vfp.processid, _vfp.threadid)

endproc

procedure SetUserLevel(cUsername as string, nUserLevel as integer)

return this.oUser.SetUserLevel(cUsername, nUserLevel, this.cToken, sys(0), _vfp.hwnd, _vfp.processid, _vfp.threadid)

endproc

procedure GetUserLevel2(cUsername as string) as integer

return this.oUser.GetUserLevel(cUsername, this.cToken, sys(0), _vfp.hwnd, _vfp.processid, _vfp.threadid)

endproc

enddefine

define class localuser as relation

cUsername = ""
lAnyUser = .f.
oUser = .null.
nUserLevel = 0
cToken = ""
cCLSID = "{8C1A9254-4C65-4B69-83B7-7D0A5A28FC05}"
cServer = ""

procedure init (cServer as string) as object

if vartype(cServer) == "C"
this.cServer = cServer
endif

local lCreatedObject as Boolean
try
* set procedure to classes\base_dcom.prg additive
* this.oUser = newobject("user", "com\users\user.prg")
this.oUser = createobjectex(this.cCLSID, this.cServer)
lCreatedObject = .t.
catch to oDear
lCreatedObject = .f.
endtry

return lCreatedObject

endproc

procedure login(cUsername as string, cPassword as string) as Boolean

this.logout()

this.cToken = this.oUser.login(cUsername, cPassword, sys(0), _vfp.hwnd, _vfp.processid, _vfp.threadid)

if left(this.cToken, 7) # "#TOKEN#"
return .f.
endif

this.cUsername = cUsername

this.nUserLevel = this.oUser.GetUserLevel(cUsername, this.cToken, sys(0), _vfp.hwnd, _vfp.processid, _vfp.threadid)

return .t.

endproc

procedure SetPassword(cPassword as string) as Boolean

lSuccess = this.oUser.SetPassword(this.cUsername, cPassword, this.cToken, sys(0), _vfp.hwnd, _vfp.processid, _vfp.threadid)
return lSuccess

endproc

procedure SetUserName(cUsername as string) as VOID

this.cUsername = cUsername

endproc


procedure GetUserName() as string

return this.cUsername

endproc

procedure GetUserLevel() as integer

return this.nUserLevel

endproc

procedure logout

this.nUserLevel = 0
* Do something on remote object?

endproc

procedure GetUserFullName(cUsername as string) as string

return this.oUser.GetUserFullName(cUsername)

procedure GetUserPhone(cUsername as string) as string

return this.oUser.GetUserPhone(cUsername)


enddefine
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform