Network Username/Password Windows Host Model Scripting Object

Posted on 2005-05-04
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!
Question by:IUFITS
    LVL 6

    Accepted Solution

    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++

    LVL 3

    Author Comment

       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 = ""
            MsgBox (username)
        End If

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
    Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
    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.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now