Logging into a MFP web interface using vb.net - vb.net

I am trying to use a VB windows form app to control multiple MFP's. I would like to be able to log in to the MFP's with a single button click as the username and passwords are all the same. I have been able to do this on other web interface pages but the web interface page on these Toshiba MFP's is different. It has a main page an then a folder with other page elements and JavaScript's. Any help or direction is appreciated.
` Dim UN As String = "admin"
Dim PW As String = "123456"
WebBrowser1.Document.Forms(0).All("login").SetAttribute("value", UN)
WebBrowser1.Document.Forms(0).All("passwd").SetAttribute("value", PW)
[]

Related

How to get HtmlDocument & active HtmlElementd from default web browser

Dim webBrowser1 As Object = New WebBrowser
webBrowser1 = Process.Start(MemSite(CurrCell), ProcessWindowStyle.Maximized)
Dim HtmlDoc As HtmlDocument = webBrowser1.Document
Dim htmlElem As HtmlElement = HtmlDoc.All.Item(0)
If htmlElem.TagName = "HTML" Then
End If
Trying to get Active elements from default web browser without using
form layout + Web Browser Control.
and post the username + password.
Short answer: What you are trying to achieve is not possible.
Long answer:
Each web browser has its own way of managing the HTML DOM. There isn't a universal solution that'll work for all of them.
The only way this can be done is if you get ahold of an API for each web browser you want to target, and then decide which API to use based on which the user has installed as his/her default. Doing so will require A LOT of time and effort, but it is technically possible (assuming the browsers you want to target have a public API that can be used for automation).

Access form ressources from code in VS 2015 (VB.NET)

Good morning,
Context:
I have a localized VB.NET form, called Menu.vb
The localization is activated, so I have multiple ressource files attached, Menu.resx, Menu.fr-FR.resx...
I have added a custom string to those ressources files, and I would like to display this string in a MsgBox, depending on the culture selected.
Problem:
I can't access the form ressource from within the form code.
Could you please help me with this?
Thanks a lot,
Maxime
Use System.ComponentModel.ComponentResourceManager to access the form resources:
// inside the form code - 'this' represents the Form instance
Dim resources As ComponentResourceManager = New ComponentResourceManager(this.GetType())
// get the string you want
resources.GetString("nameOfTheStringResource")
// optionally you can access the same with specific culture
resources.GetString("nameOfTheStringResource", new CultureInfo("en-US"))

FindElementsBy id for username and password

I've started learning selenium web driver. I've come across an issue. When I navigate to my URI, I come across an windows authentication window before I can access my web page. Im using C# for the scripting. Ive got the code that I should be using:
// Get the page elements
var userNameField = driver.FindElementById("usr");
var userPasswordField = driver.FindElementById("pwd");
var loginButton = driver.FindElementByXPath("//input[#value='Login']");
// Type user name and password
userNameField.SendKeys("admin");
userPasswordField.SendKeys("12345");
But this is only good if you have a normal login page. I can't get to the elements or get the Fire Path id as the window authentication pop will not let me. Can someone please help me with this. How do I automate this process
Thanks
We have a way to handle this by passing username and password inside URL like the following:
driver.Navigate().GoToUrl(https://<username>:<password>#<URL>");
e.g.
driver.Navigate().GoToUrl(https://auth_user1:userpassword1#www.google.com");
Hope this helps!

Windows 8 Metro Show Webview in Popup and pass response back OAUTH2 Visual Basic

This is my first question so hello and thanks for your support!
I am currently developing a windows 8 store app.
I need to login to an OAUTH website and get the response token to save as a string.
I would like this to appear in a popup, have the user login, then close once a response is received.
I can get the webview to pop up and I can navigate to the page. But how do i handle the response and close. I speak VB.
Thanks again!
Edited to add my code:
Dim url As New Uri("https://aurlthatidontcontrol")
WebView1.Navigate(url)
PopUp.IsOpen = True
MY popup opens and the login for the url is presented.
Once I log in I should get a response from that server which includes an access token
I want to get that token into my app and save it as a string, then close the popup
Ok I figure it out.
Instead of actually calling a webview I used the web-broker authentication. Details
This allows the service login to "pop" on the screen and I can capture the result like this:
Dim webresult As WebAuthenticationResult = Await
WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, StartURI, endURI)
Dim finalresponse() As String = webresult.ResponseData.ToString.Split("=")
Dim currentuserstoken As String = finalresponse(1)
Return currentuserstoken
Use the InvokeScript method on the WebView class to call JavaScript code to collect information from the response and return it the calling code. If there is no script in the page you control, use "eval" as the function name and pass arguments to it.
Alternatively, use window.external.notify in JavaScript to fire the ScriptNotify event (link includes an example).

Disable Links to My Site profiles in Sharepoint 2010

I would like to utilize some of the social collaboration features in Sharepoint 2010, such as the Noteboard webpart and tagging, but do not want to use the My Site profile pages.
I have already built a custom control that redirects from the userdisp.aspx page to a custom user profile page. I would like to continue to use that custom profile page. However, it seems like user profile links that are generated by the Noteboard webpart, for example, go directly to the /Sites/MySites/person.aspx page without being routed through the /_layouts/userdisp.aspx page. So my profile redirect control doesn't catch it.
In Sharepoint Central Admin, under Manage Service Applications > User Profile Service Application > Manage User Permissions, I have only checked the box for "Use Social Features", not "Create Personal Site," so I am not sure why the profile page is not linking to the old userdisp.aspx page.
Is it possible to redirect these links back to the userdisp.aspx page?
It appears to be hardcoded into the webpart.
I looked at Microsoft.SharePoint.Portal.WebControls.SocialCommentControl and the link comes from UserProfile.PublicUrl, which is defined as:
public override Uri PublicUrl
{
get
{
string userProfileUrl = UserProfileGlobal.GetUserProfileURL(
this.m_objManager.UserProfileApplicationProxy,
this.m_objManager.PartitionID,
"?accountname=",
this.m_UserProfileFields["AccountName"].ToString());
if (!string.IsNullOrEmpty(userProfileUrl))
return new Uri(userProfileUrl);
else
return (Uri) null;
}
}
which eventually calls:
internal static string GetUserProfileURL(string profileWebUrl, string strIdentifier, string strValue)
{
if (string.IsNullOrEmpty(profileWebUrl))
return (string) null;
else
return PersonalSpaceGlobal.EnsureTrailingSlash(profileWebUrl)
+ "Person.aspx"
+ strIdentifier
+ (strIdentifier.Equals("?accountname=", StringComparison.OrdinalIgnoreCase)
? SPHttpUtility.UrlKeyValueEncode(strValue).Replace(":", "%3A")
: SPHttpUtility.UrlKeyValueEncode(strValue));
}
I can think of two workarounds:
Add jQuery to your page to change the URL (selector = span.socialcomment-username > a)
Create your own webpart containing a custom control that inherits from SocialCommentControl, which overrides RenderComment.
Overriding RenderComment is probably going to be messy. You will need to copy the decompiled code for the method just to change the following into your own code:
SocialCommentControl._GetProperty(
comment,
SocialCommentControl.SocialCommentProperty.PublicPage)
Hopefully, there are no internal method calls within RenderComment's 67 lines of code. Otherwise, it is going to be a lot more difficult to implement. It would be a lot easier if you could simply override _GetProperty, but unfortunately, it is a static method.
All of that to say, I would probably recommend the jQuery option over extending SocialCommentControl.