?
Solved

Network Username/Password Windows Host Model Scripting Object

Posted on 2005-05-04
2
Medium Priority
?
167 Views
Last Modified: 2013-11-20
I'd like to create a C++ .DLL that I can call from other environments (Powerbuilder namingly).  I need to get the user's domain and network username (not the windows username if it happens to be different than the network authentications in the case of VPN's for instance.  I've figured out a way to get what I want in VB with a reference to the Windows Host Model Scripting Object but I'm having a damned hard time using the ActiveX DLL in the traditional way windows DLL's are used (I know there's a way around it by writing a wrapper for the compiler but I haven't had time to do that).

Now, does anybody have a better way to accomplish this or can they show me an example of how to reference the windows scripting object from a C++ DLL.  Thanks!
0
Comment
Question by:IUFITS
2 Comments
 
LVL 6

Accepted Solution

by:
nabehs earned 2000 total points
ID: 13934003
To define the library, put at the top of cpp file:

#undef GetFreeSpace
#import "c:\windows\system32\wshom.ocx"

If you post the VB code to access the user domain and user name, I may be able to help converting it to c++

0
 
LVL 3

Author Comment

by:IUFITS
ID: 13939215
   On Local Error Resume Next
   
    Dim net As WshNetwork
    Dim username As String
    Set net = New WshNetwork

    username = net.UserDomain & "\" & net.username
    username = LCase(username)
   
    If Err.Number <> 0 Then
        username = ""
    Else
        MsgBox (username)
    End If
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question