I modified my username in Control Panel -> User Accounts -> Change Your Name.
But when I use the GetUserName function, it returned my old username.
How do I get the new one?
EDIT 1
Here's the code as requested:
char user[UNLEN + 1];
DWORD user_len = UNLEN + 1;
GetUserName(user, &user_len);
Try to use the API GetUserNameEx, and passing as a format NameDisplay. I guess you changed the display name of the user, not the logon name.
Related
I've been trying to update our API call to the CIM interface for Authorize.net to hide the Billing Address fields on the hosted profile page.
The documentation states that when call the token creation function, passing in a setting "hostedProfileBillingAddressOptions" with a value of "showNone" will hide the billing address part of the form, however when I pass in this setting I am still getting the billing address showing.
I've verified that I'm passing the setting correctly (added the same way as the "hostedProfileIFrameCommunicatorUrl" and "hostedProfilePageBorderVisible" settings) and if I pass an invalid value for the "hostedProfileBillingAddressOptions" option, the Token creation function will return an error
Is there something else that this option is dependent on, such as an account setting or another settings parameter?
For reference, I'm testing this in the Sandbox system and I'm using the dotNet SDK, my test code for calling the API function is as follows
Public Shared Function CreateHostFormToken(apiId As String, apiKey As String, branchId As Int64, nUser As Contact, iframeComURL As String) As String
Dim nCustProfile = GetCustomerProfile(apiId, apiKey, branchId, nUser)
Dim nHost = New AuthorizeNet.Api.Contracts.V1.getHostedProfilePageRequest()
nHost.customerProfileId = nCustProfile
' Set Auth
Dim nAuth = New Api.Contracts.V1.merchantAuthenticationType()
nAuth.ItemElementName = Api.Contracts.V1.ItemChoiceType.transactionKey
nAuth.name = apiId
nAuth.Item = apiKey
nHost.merchantAuthentication = nAuth
' Set Params
Dim settingList As New List(Of Api.Contracts.V1.settingType)
Dim nParam As New Api.Contracts.V1.settingType With {.settingName = "hostedProfileIFrameCommunicatorUrl",
.settingValue = iframeComURL}
settingList.Add(nParam)
nParam = New Api.Contracts.V1.settingType With {.settingName = "hostedProfilePageBorderVisible",
.settingValue = "false"}
settingList.Add(nParam)
nParam = New Api.Contracts.V1.settingType With {.settingName = "hostedProfileBillingAddressOptions",
.settingValue = "showNone"}
settingList.Add(nParam)
nHost.hostedProfileSettings = settingList.ToArray
Dim nX = New AuthorizeNet.Api.Controllers.getHostedProfilePageController(nHost)
Dim nRes = nX.ExecuteWithApiResponse(GetEnvironment())
Return nRes.token
End Function
I've looked through the SDK code as well, and I don't see anything there that would be preventing the setting from being passed through.
Has anyone come across this issue, or successfully set the card entry form to hide the billing address?
There turned out to be two parts to the solution to this problem:
In order to use the "hostedProfileBillingAddressOptions" option, you need to use a newer version of the capture page than I was using. I was using "https://secure2.authorize.net/profile/", while the new version is "https://secure2.authorize.net/customer/". Added bonus, the new URL provides a much nicer and modern looking form.
However, once this was working, I then had the problem that on entering the card, a validation message told me that "address and Zip code are required", despite not being visible. I did also make sure that I had the option "hostedProfileBillingAddressRequired" set to false (which is it's default value anyway)
The response from Authorize.net support is that in order to capture card without an address, the option "hostedProfileValidationMode" must be set to "testMode".
This is not mentioned in the documentation (at least as far as I could see), so may not be something that other people are aware of since it is a little counter-intuitive to use 'testMode' on a live environment.
It's not ideal since validating the card for a customer account will send a transaction email to the merchant, but it seems there is not another way around this just now.
In summary, to allow the customer to add a credit card to their profile without having to provide an address, you need to specify the following options:
Form URL for capture - https://secure2.authorize.net/customer/
getHostedProfilePageRequest -
hostedProfileIFrameCommunicatorUrl: *your URL*
hostedProfilePageBorderVisible: false //assuming you are using an iFrame
hostedProfileValidationMode: testMode
hostedProfileBillingAddressOptions: showNone
On Windows 7 to retrieve the name of a logged on user I can do this:
LPTSTR pUserName = NULL;
DWORD dwcbSzUserName = 0;
//'dwSessID' = user session ID
if(WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, dwSessID, WTSUserName, &pUserName, &dwcbSzUserName))
{
//Got user name in 'pUserName'
}
if(pUserName)
WTSFreeMemory(pUserName);
But on Windows 8 it returns some abbreviated name, for instance, "john_000" when the actual user's name is "John A. Doe".
So what is the way to retrieve the name of the logged on user (and possibly their email) on Windows 8 with C++ using WinAPIs as it's shown at log-on screen?
You could try NetUserGetInfo with USER_INFO_23 to get full name.
Something basically like:
//Got user name in 'pUserName'
NetUserGetInfo(NULL, pUserName, 23, my_USER_INFO_23);
//Got display name in my_USER_INFO_23.usri23_full_name
On Windows 7 to retrieve the name of a logged on user I can do this:
LPTSTR pUserName = NULL;
DWORD dwcbSzUserName = 0;
//'dwSessID' = user session ID
if(WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, dwSessID, WTSUserName, &pUserName, &dwcbSzUserName))
{
//Got user name in 'pUserName'
}
if(pUserName)
WTSFreeMemory(pUserName);
But on Windows 8 it returns some abbreviated name, for instance, "john_000" when the actual user's name is "John A. Doe".
So what is the way to retrieve the name of the logged on user (and possibly their email) on Windows 8 with C++ using WinAPIs as it's shown at log-on screen?
You could try NetUserGetInfo with USER_INFO_23 to get full name.
Something basically like:
//Got user name in 'pUserName'
NetUserGetInfo(NULL, pUserName, 23, my_USER_INFO_23);
//Got display name in my_USER_INFO_23.usri23_full_name
I'm creating a user with the NetUserAdd API. It returns successfully, the user has a User folder and I can see the username with wmic useraccount get name. However, the created user is not visible under the control panel, nor on the logon screen. I assume that I need to add the user to some group but I don't know which or how.
Here is how I create the user:
USER_INFO_1 user_info;
ZeroMemory(&user_info, sizeof(user_info));
user_info.usri1_name = userName;
user_info.usri1_password = password;
user_info.usri1_priv = USER_PRIV_USER;
user_info.usri1_flags = UF_SCRIPT | UF_DONT_EXPIRE_PASSWD;
DWORD dwLevel = 1;
DWORD dwError = 0;
NET_API_STATUS nStatus = NetUserAdd(NULL, dwLevel, (LPBYTE)&user_info, &dwError);
How can I make the user visible on the logon screen?
You have created the user but you need to add it to the users group using NetLocalGroupAddMembers.
EDIT: Just realized I was providing the method for .NET. See this example for C++.
The user was not showing up on the welcome screen because it was not added to the Users group. This is how to do it:
LOCALGROUP_MEMBERS_INFO_3 lmi3;
ZeroMemory(&lmi3, sizeof lmi3);
lmi3.lgrmi3_domainandname = user_info.usri1_name;
DWORD err = NetLocalGroupAddMembers(NULL, L"Users", 3, (LPBYTE) &lmi3, 1);
I'm trying to add a user, programmtically, to a field of Type="User" in a SharepointList. Since I do not know the user's unique ID within the site in advance, I'm using the ResolvePrincipals function to add the user to the SPUserCollection as follows:
Dim managerDN() As String = {"some.user#email.com"}
Dim principalInfo() As PrincipalInfo = people.ResolvePrincipals(managerDN, SPPrincipalType.User, True)
Console.WriteLine(principalInfo(0).UserInfoID)
Problem is when I look at the UserInfoID, which is what I'm looking for, I get back -1. I assumed that the ResolvePrincipals function would add the user to the site user collection automatically (According to MSDN documentation) and create a unique, positive UserInfoID in the process. I'm not sure if I have the right idea or not
I always use this code:
SPUser user = web.EnsureUser("login");
SPFieldUserValue value = new SPFieldUserValue(web, user.ID, user.LoginName);
If you only have an email address, you could use this:
SPUser user = web.AllUsers.GetByEmail("email");
if (user != null)
{
SPFieldUserValue value = new SPFieldUserValue(web, user.ID, user.LoginName);
}
I'm not really sure if GetByEmail returns null or throws an error if the user cannot be found, so be sure to check that first !