I tried the automation 'Windows Script Host Object Model'.WshNetwork but none of functions worked for me. I only get the login name and not the name of the user.
The ENVIRON function (for example environ('Username') gave me only the loginname aswell.
ah ok you need to read the AD. No problem. I would post here the whole solution, but i'm at home and here is no AD to test :-( . So, lets start with theory. You must only know the DC and domain (thats no problem).
You can solve this for example with an vbs script with return parameter. This script your call from NAV and you read the returnvalue. The other method is, let check my brain, it think it was ADO. Because since Win2000 you can fire up sql commands to the machine :-)
so, with ADO and provider = (i hope its the true name) "ADsDSOObject"
you can fire up "SELECT * FROM [url=LDAP://dc=YourDomainName]LDAP://dc=YourDomainName[/url] WHERE objectClass = 'user' and objectCategory = 'person' and uid = 'Angela Merkel' ".
Also possible:
check the automation: "Active DS Type Library"
So, test one or both (theory) solutions.
If you need a example, if you doesn't find the solution, lets us know.
WindowsObject.reset;
WindowsObject.setfilter(ID,environ('Username'));
if WindowsObject.findset(false) then begin
repeat
message(WindowsObject.Name + ' / ' + WindowsObject."Distinguished Name");
until WindowsObject.next = 0;
end;
Actual solution for OBJECT Codeunit 418 Login Management:
PROCEDURE GetUserName@1100520000(UserID@1100520001 : Code[20]) : Text[250];
VAR
User@1100520003 : Record 2000000002;
WindowsLogin@1100520004 : Record 2000000054;
WindowsObject@1100520000 : Record 2000000050;
BEGIN
IF UserID <> '' THEN
IF User.GET(UserID) THEN
EXIT(User.Name)
ELSE BEGIN
WindowsLogin.SETFILTER(ID,STRSUBSTNO('@*%1',UserID));
IF WindowsLogin.FINDFIRST THEN BEGIN
WindowsObject.SETRANGE(SID,WindowsLogin.SID);
IF WindowsObject.FINDFIRST THEN
EXIT(WindowsObject.Name);
END;
END;
END;
Answers
ERP Consultant (not just Navision) & Navision challenger
Thanks for the link.
I tried the automation 'Windows Script Host Object Model'.WshNetwork but none of functions worked for me. I only get the login name and not the name of the user.
The ENVIRON function (for example environ('Username') gave me only the loginname aswell.
Is there anything I have missed?
](*,)
is not enough :?:
What do you need also :?:
Regards
In the form "Windows users & groups" i want the column Name and not the ID
You can solve this for example with an vbs script with return parameter. This script your call from NAV and you read the returnvalue. The other method is, let check my brain, it think it was ADO. Because since Win2000 you can fire up sql commands to the machine :-)
so, with ADO and provider = (i hope its the true name) "ADsDSOObject"
you can fire up "SELECT * FROM [url=LDAP://dc=YourDomainName]LDAP://dc=YourDomainName[/url] WHERE objectClass = 'user' and objectCategory = 'person' and uid = 'Angela Merkel' ".
Also possible:
check the automation: "Active DS Type Library"
So, test one or both (theory) solutions.
If you need a example, if you doesn't find the solution, lets us know.
Regards
these table contains the following coloumns:
If you need more / other fields, then LDAP://
Regards.
Thanks for the information and the good examples.
I am trying to get the Name from the table "windows object" but I cant get it to work. The key to the table is "GUID" and I dont have that value.
Also when i am trying to set a filter to the table and use FIND to retrieve the value I only get error messages.
doesn't work?
Kind regards!
So, please write [Solved] infront of the subject in your first post.
Regards
PROCEDURE GetUserName@1100520000(UserID@1100520001 : Code[20]) : Text[250];
VAR
User@1100520003 : Record 2000000002;
WindowsLogin@1100520004 : Record 2000000054;
WindowsObject@1100520000 : Record 2000000050;
BEGIN
IF UserID <> '' THEN
IF User.GET(UserID) THEN
EXIT(User.Name)
ELSE BEGIN
WindowsLogin.SETFILTER(ID,STRSUBSTNO('@*%1',UserID));
IF WindowsLogin.FINDFIRST THEN BEGIN
WindowsObject.SETRANGE(SID,WindowsLogin.SID);
IF WindowsObject.FINDFIRST THEN
EXIT(WindowsObject.Name);
END;
END;
END;