cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DonAIR
Level 6

Get just the domain from SdLogonUserInformation?

I need to get just the domain name, not the domain\username back from this dialog? Is there an easy solution to this?
Labels (1)
0 Kudos
(2) Replies
DonAIR
Level 6

So, I figured out a string way to get this, now I need the opposite but not sure how to:

Basically I get this:

DOMAIN\USERNAME

To get the domain I am doing this:

// Get Domain Name
sCharacterRemove = "\\";
nResult = StrFindEx ( sUserName, sCharacterRemove, 0 );
if (nResult < 0) then
MessageBox("Domain Name not found, setup will abort.", SEVERE);
else
StrSub ( sDomainOnly, sUserName, 0, nResult );
endif;


so:
sUserName = DOMAIN\USERNAME
sDomainOnly = DOMAIN

but I also need to pull out the Username as well, not sure how to get everything from the right of the "\" properly.
0 Kudos
DonAIR
Level 6

Probably a crappy convoluted way, but here is what I got working:


// Get Domain Name
sCharacterRemove = "\\";
nResult = StrFindEx ( sUserName, sCharacterRemove, 0 );
if (nResult < 0) then
MessageBox("Domain Name not found, setup will abort.", SEVERE);
else
StrSub ( sDomainOnly, sUserName, 0, nResult );
endif;

// Get the Domain name length to use to get the User Name Below
nDomainLength = StrLengthChars (sDomainOnly);
// Add 1 to avoid the \
nDomainLength++;

// Get User Name
sCharacterRemove = "\\";
nResult = StrFindEx ( sUserName, sCharacterRemove, 0 );
if (nResult < 0) then
MessageBox("User Name not found, setup will abort.", SEVERE);
else
StrSub ( sUserNameOnly, sUserName, nDomainLength, nResult );
endif;
0 Kudos