VB .NET: Logged in user information - vb.net

I'm writing software in VB .NET (2005) which uses the Windows user information as login credentials - just the username. I've found Environment.UserName which works for the username (as you would expect).
However, I need more information - I need the full name of the user (as shown on the Start Menu). It seems this information is stored... somewhere, as Windows is able to use it for things like permissions on file shares.
I've heard there's calls in user32.dll that can do this, but I'd like a .NET method if it's at all possible. I also have a SID for the user, if that helps at all.
Does anyone know the best way to get this additional information?

It seems the System.DirectoryServices namespace is exactly what I'm looking for.
Always seems that you find the answer right after you ask :)
For future reference:
Dim ent As New DirectoryServices.DirectoryEntry("WinNT://<Domain>/<Username>")
Dim props As DirectoryServices.PropertyCollection = ent.Properties
Debug.Print(props.Item("FullName").Value)

Related

SMS gateway for Dynamics 365

First of all, I have to say that I am NET developer (C#) and my knowledge on Dynamics 365 is pretty limited. Nevertheless my employer thought that I am good enough to make that thingy from post title :)
After couple of hours researching and reading, I found this video https://www.youtube.com/watch?v=6LwZLoXS6jo which address on how to create and send SMS from Dynamics. I am aware that this require me to create new Dynamics entities, at least SMSMessage and SMSMessageTemplate, but at least I found out how to do this :)
I understood everything stated there, but as i already said, due to my lack of knowledge on Dynamics 365, I got problems with (probably) basic things regarding Dynamics.
Here are those problems:
1. As far as I can tell, in order to build SMS gateway, first thing I need to do is to add new menu item inside Dynamics 365. I presume that this new menu item should reside inside 'Contacts' menu (contacts.jpg, marked with red box) but I am not sure on how to achieve this. Please note, I do not want someone to provide me with some magic solution, I just need someone to provide me with valid links that I can use to learn about this and solve my own problem :)
2. When new menu item is in place, and user click on it, I would like to open up a form for user to select SMS template that will be used and maybe setup some other values. Same again, U do not need to help me with exact code, just with some usable links :)
3. Inside that form that user will open on menu click, I would like to know how to get list of selected contacts (from grid at contact.jpg)
When I (finally) have that list of contacts, I will create SMS entities mentioned above (video link) and everything will fall in place and (hopefully) work.
I am aware that this is probably too much to ask, cause Dynamics 365 is rather complex, and people are spending great amounts of money and their time learning to became Dynamics developers, but without help, Dynamics is making me running in circles chasing my own tail :) and getting nowhere.
Also, I will be using online Dynamics 365 so bare in mind that any solution should work with it.
if any of U think that I missed or got something wrong, please let me know.enter image description here
So basically to get you started, you should:
1) Create a solution in Settings => Customizations => Solutions
2) Add contact entity to that solution (by choosing "Add existing" under Entities pane). Don't click "Add all assets" you will need only contact metadata to get going
3) Create jScript file and add a web resource to CRM (nothing really complicated, just go to web resources in you solution and click "Add new" and specify type of your web resource as jScript and target your file).
4) Now download http://www.xrmtoolbox.com
5) For now you are interested only in plugin "Ribbon Workbench"
6) Now simply choose your solution and contact - you will see command bars for contact homepage, list and form. This is pretty strainghtforward - simply drag and drop a button wherever you like, create a command using workbench and bind the button with the command (simply choose it from a drop-down). The command you are interested in is Custom Javacript. Here you specify your web resource and name of the function that you want to call. You can also specify parameters that should be passed inside your function for example ids of selected items (if you are on the list of records).
There are many approaches to fulfil your specific needs, but being able to call a custom javascript function from a button should be a good starting point, the rest is simply the knowledge of CRM SDK, so how to create an entity using API or open a form or open a web resource - everything is very well documented and you can get it simply by asking google, so I will not post any blog here, not to advertise too much. Also I's suggest downloading latest CRM SDK (https://www.microsoft.com/en-us/download/details.aspx?id=50032) - you have many sample code there, regarding plugins and some form modifications, you should also check this out.
To make it easier for you, you should refer to this "menu" as "Command bar" or "Ribbon", so rather look for "adding custom button to command bar CRM 2016" and you will be all good. Also to make a form for choosing a template, you will probably need some custom web resource, so "creating custom html5 web resource CRM 2016" should give you some good examples.

OAuth2 w/ Google Client API 1.8.1

I have been using the Google Client API in a .NET web application - but need to update to the latest version (both to use the most recent code but also to lose the need for the DotNetOpenAuth.dll.) The latest version (1.8.1) has a totally redesigned OAuth interface (using google.apis.auth) and I can't seem to even get started w/ it.
Previously I had written code that handled generating an AuthorizationURL (as needed) and creating IAuthenticator and IAuthorizationState objects - storing the refresh token in a sql database as needed. I was also about to retrieve "UserInfo" about the user as needed (once authenticated.)
Now - I'm unclear on how to handle the generation of the AuthURL (do I have to do it 100% manually?) and how/what I need to pass to the BaseClientService.Initializer when working w/ client API (such as Google Drive.)
Also - previously I wrote methods to "store" and "retrieve" credentials from the database - now it seems I would need to write a class based on IDataStore? But I'm not sure if this is even correct (let alone find a decent sample/doc anywhere.)
Finally - it doesn't seem like google.apis.auth handles anything w/ regards to UserInfo - I have to grab google.apis.oauth2 - but that .dll has even LESS documentation/sample code out there.
Any advice on where to start? The google.apis sample code seems decent for performing basic api tasks but all the Oauth2 information is very basic, uses file data storage and seems glossed over.
Thanks!
First of all, take a look at https://developers.google.com/api-client-library/dotnet/guide/aaa_oauth. All the documentation that you might need is there, and if something is missing let us know!
You are right, you already have an implementation of FileDataStore, and we are planning to create EFDataStore as well for the next release.

Web Dynpro for ABAP Explanation Text (Green Underline) not working for certain users

I have recently added Explanation text to certain fields on the SRM Contract screen (both standard and cusom fields). The user that I unit tested with worked fine, however most other users do not work. After investigation I've found that it is not just the Explanation Text that I've added, but all Explanation Text that is missing.
According to the sap help entry the behaviour is similar to what I would expect for Help mode = off.
Is it possible to turn Help mode on or off on a per user (or role) basis, and where should I look to find this?
you already found it: SAP Help says:
"You can activate the help mode either in the personal settings in the portal or in the associated URL Parameter" ... means in personal Settings, but I feel that you want it globally not on personal base or in the associated URL Parameter. The latter means you'll have to find the application in the Portal Content, there you can find URL Parameter and i would try adding HELPMODE=ON... does this help you?
start by rightclicking you application "Technical Help" or "..Help" and see what application you are looking for. Then Google the application and add +"Portal Content", I think then you'll find it.
regards, zy

Liferay document library API - help required for a beginner

I am completely new to Liferay and unfortunately have limited knowledge of portlet, liferay APIs etc.
I have been asked to use liferay's document library API to add documents in one of our portlet.
We are using 5.2.3 version currently. I could find the javadocs which has methods like addFileEntry, addFile in classes such as DLFileEntryLocalServiceUtil, DLLocalServiceUtil etc, but having a very hard time to understand which method to use or which class to use.
Also, most of these APIs takes parameters such as userId, groupId, companyId etc etc. From where can I get that?
I know I am asking some very basic questions and should first try to understand the key concepts behind liferay, but unfortunately have been given very limited time :(. My bad luck.
It would be really helpful, if anyone can provide some sample code base with some explanation on it or guide me to any link.
Thanks,
Ashish
you can get userid,companyid,scope id from this method....
ThemeDisplay td = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
long userId = td.getUserId();
like wise you can get companyid,scopeid and all..
To add documents you can use...
DLFileEntry file=DLFileEntryLocalServiceUtil.addFileEntry(userId,
groupId,
folderId,
myfile.getName(),//name
myfile.getName(),//title
"",//description
"",//changelog
"",//extra seeting
myfile,
serviceContext);
Try this..
This approach suggested by Lucky Boy will not check permissions. If you want that the permissions will be checked use DLFileEntryServiceUtil instead of DLFileEntryLocalServiceUtil.
DLFileEntry file=DLFileEntryServiceUtil.addFileEntry(
folderId,
myfile.getName(),//name
myfile.getName(),//title
"",//description
"",//changelog
"",//extra seeting
myfile,
serviceContext);

Hooking into Terminal Services Manager

Has anyone ever come across a way of a way to create an app that kind of mimics what Terminal Services manager does in Windows2003/XP.
I would like to write something that would either go and query a farm of server every n secs a get me a list of users logged in, there process's etc or do maybe type a username in and it goes and finds the user in the farm and returns their details.
Cheers
Luke
I would suggest using Cassia, a .NET library which uses internally the Wtsapi32 library Arnshea mentioned. For example, to list all users logged into a server:
Dim manager As New TerminalServicesManager()
Using server As ITerminalServer = manager.GetRemoteServer("your-server-name")
server.Open()
For Each session As ITerminalServicesSession In server.GetSessions()
If Not string.IsNullOrEmpty(session.UserName) Then Console.WriteLine(session.UserName)
Next
End Using
I've hacked this using qwinsta (query winstation is the mnemonic) and string parsing/regular expressions. Beware of firewalls and impersonation.
Take a look at psexec and the other ps* utilities from Microsoft (originally from SysInternals).