Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
10
Erster Beitrag:
vor 3 Jahren, 4 Monaten
Letzter Beitrag:
vor 3 Jahren, 4 Monaten
Beteiligte Autoren:
JP, Paulo Oliveira

[WD19] - Getting logged in user name and description

Startbeitrag von JP am 04.07.2014 06:59

Hello All,

I need to get the user login name and the description of the user from the Windows User Administration. The login name I can get easily enough with NetworkUser(). But under windows the login name can have a Full Name field and a Description field. Does anyone know how to get that info?

See image attached for further clarity.

Thanks
[attachment 1043 Capture.JPG]

Antworten:

did you try using the ldap functions?

Check this example in the help:
http://doc.windev.com/en-US/?3032130

von Paulo Oliveira - am 04.07.2014 07:30
Hi Paulo,

Thanks, this looks like it will give me what I need. Having read the help I am not clear on what the Session Name and the DN is in the function:

= LDAPListChildren( , )

= LDAPListChildren("MySession", "CN=Users,DC=tdf, DC=local")

Can I use any string for Session Name?

And what do I use for DN (what is a DN?) ? How is it constructed?

Thanks

von JP - am 04.07.2014 07:53
HI Paulo,

So I tried the following from the help but it always give me an error saying "server down". I dont know what I need to enter for the various parameters (newbie :) )

LDAPReset()
LDAPSession.Host = "local" // ?? No idea what to use
LDAPSession.Port = 389
LDAPSession.Version = 3
LDAPSession.User = "myloginname"
LDAPSession.Password = "mypassword"

// Connection
LDAPConnect("MySession")

Trace( ErrorInfo() )

Any suggestions?

von JP - am 04.07.2014 08:17
Can I use any string for Session Name?
Yes

LDAPSession.Host = "local" // ?? No idea what to use
It depends if your user is a domain user or local user.
LDAPSession.Host is the name of the server that holds the users.
If it's a local user it's your pc name if it's a domain user ti's the name of one of the domain servers.

use something like this (not tested):
LDAPReset()
LDAPSession.Host = Replace(ExtractString(SysEnvironment("LOGONSERVER"),2,"=",FromBeginning),"\\","")
//LDAPSession.Port = 389
//LDAPSession.Version = 3
//LDAPSession.User = NetworkUser()
LDAPSession.User = "myloginname"
LDAPSession.Password = "mypassword"
// connection
IF NOT LDAPConnect("ldap_conn") THEN
Error(ErrorInfo())
RETURN
END

DN explanation:
http://msdn.microsoft.com/en-us/library/aa366101(v=vs.85).aspx
http://community.spiceworks.com/how_to/show/2243-constructing-ldap-distinguished-names

von Paulo Oliveira - am 04.07.2014 10:56
Thanks Paulo. I have tried your example and various variations on both my local laptop and our server but it always replies with "server down". I am not sure what the cause might be.

von JP - am 04.07.2014 13:12
Did you check if you can access the server on port 389 ?
Try to do telnet your server on port 389

If you can't do it probably you have some firewall problem or the ldap is defined to listen on any other port.

von Paulo Oliveira - am 04.07.2014 14:18
HI Paulo,

I shall check that and get back to you.

Incidentally, in Visual FoxPro there is a function called GetObject() which can be used to return an object reference to an Automation object from a given file parameter and to assign a reference to the object through a memory variable or array element. For example, I can use this:

Var_Object_Reference = GetObject( "WinNT://" + Var_User_Domain + "/" + Var_Login_Name ) + ",User" )

This returns an object reference in to variable: Var_Object_Reference

Now I can easily access the user's login record details like this:

Var_Object_Reference.FullName // Returns the full name
Var_Object_Reference.Description // Returns the description


Is there anything like this in WinDev because this seems a very easy solution ... ?

von JP - am 04.07.2014 14:29
I don't know but you have one example of the ldap implementation under windev dir in:
\Examples\Complete examples\WD LDAP Explorer

von Paulo Oliveira - am 04.07.2014 15:37
Thanks Paulo. I will study it.

von JP - am 04.07.2014 15:50
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.