Windows Authentication to read or select

Hello,
who can help.
I need the Windows user name and domain.
These values should be written on a label.
I did it with a JavaScript statement, the data can already get,
but can not write to a label or tag.

@Override
protected void init(VaadinRequest request) {
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);

    Label javascript = new Label("<h3>User Name</h3>",
            Label.CONTENT_XHTML);
    layout.addComponent(javascript);

    final TextArea script = new TextArea();
    script.setWidth("100%");
    script.setRows(3);
    /* ActiveXObject
     *
     * function login() {
        var Text = "";
            var objUserInfo = new ActiveXObject("WScript.network");
            document.write("ComputerName: "+objUserInfo.ComputerName+"<br>");
            document.write("UserDomain:   "+objUserInfo.UserDomain+"<br>");
            document.write("UserName:     "+objUserInfo.UserName+"<br>");  
        }
     */
    //script.setValue("document.write(new ActiveXObject('WScript.Network').UserName)");
    script.setValue("alert(new ActiveXObject('WScript.Network').UserName)");
    layout.addComponent(script);

    Button button = new Button("Click Me");
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            
        [b]

JavaScript.getCurrent().execute(script.getValue());
[/b] //is OK

Label user = new Label(“”);


—> ??? user = JavaScript.getCurrent().execute(script.getValue());


layout.addComponent(user);

}
});
layout.addComponent(button);
}

}

Why you are not using server side framewoks to handle real Windows login e.g.
http://dblock.github.io/waffle/README.html

Then you just call invoke

VaadinRequest cr = VaadinService.getCurrentRequest(); if (cr instanceof VaadinServletRequest) { Sting remoteUser = ((VaadinServletRequest)cr).getRemoteUser(); } to get the remote user.

sorry:-) Vesa

ok and thanks,
I have installed it and started (http: // localhost: 8080 / winuser /) from it’s not songs.
:frowning:

import javax.servlet.annotation.WebServlet;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinService;
import com.vaadin.server.VaadinServlet;
import com.vaadin.server.VaadinServletRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@SuppressWarnings(“serial”)
@Theme(“winuser”)
public class WinuserUI extends UI {

@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = WinuserUI.class)
public static class Servlet extends VaadinServlet {
        
}

@Override
protected void init(VaadinRequest request) {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    setContent(layout);
    
    String remoteUser = "leer";
    VaadinRequest cr = VaadinService.getCurrentRequest();
    if (cr instanceof VaadinServletRequest) {
          remoteUser = ((VaadinServletRequest)cr).getRemoteUser();
        }
    Label user = new Label("");
    user.setValue(remoteUser);
    layout.addComponent(user);

    Button button = new Button("Click Me");
    button.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
        
        }
    });
    layout.addComponent(button);
}

}

Are you sure that authentication servlet filter has been invoked?
If you enable Waffle debug.
Does it print this kind of stuff
https://groups.google.com/forum/#!topic/waffle-users/h5IojSTjYRk
to the log?

Hello Vesa,
I do not get out. :frowning:
I have the Waffle Bibliotheken.java involved but without success.
Can give me an example file?

There is step by step cookbook in Waffle site

https://github.com/dblock/waffle/blob/master/Docs/ServletSingleSignOnSecurityFilter.md

It contains info where you can get the sample web app.