This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: IIS Dynamic Parameter for Username never fails
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Mar 16, 2011
02:25 PM
IIS Dynamic Parameter for Username never fails
Hi,
I've been using the solution here:
http://kb.flexerasoftware.com/doc/Helpnet/InstallShield2011/IIS-TextSub.htm
to specify Dynamic username/password for creating an application pool. The problem I'm having is that it works too well - as in setup does not fail when creating an app pool with a non existent domain account. The app pool will show up in IIS manager with the fake account!
Has anybody encountered this problem? If so, has anybody solved this problem?
Is there any way for me to verify an account when receiving account info in a dialog? Something along the lines of
CheckDomainAccount( szUser, szPassword);
Thanks in advance,
J
I've been using the solution here:
http://kb.flexerasoftware.com/doc/Helpnet/InstallShield2011/IIS-TextSub.htm
to specify Dynamic username/password for creating an application pool. The problem I'm having is that it works too well - as in setup does not fail when creating an app pool with a non existent domain account. The app pool will show up in IIS manager with the fake account!
Has anybody encountered this problem? If so, has anybody solved this problem?
Is there any way for me to verify an account when receiving account info in a dialog? Something along the lines of
CheckDomainAccount( szUser, szPassword);
Thanks in advance,
J
(1) Reply
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Jul 23, 2014
04:27 AM
Not directly in InstallShield, but you can write a DLL to do it. I wrote a c# one for many things I needed to do, one of which was to verify account credentials. This works for local or domain accounts.
c# dll method definition...
[CODE][ComVisible(true)]
public bool ValidateAccountCredentials(string domain, string userName, string password, ref bool validCredentials, ref string errorMsg)
{
// The result.
bool result = false;
validCredentials = false;
// Lower the hostname so that matches definately work.
string localHostName = Environment.MachineName.ToLower();
try
{
using (PrincipalContext pc = new PrincipalContext(localHostName == domain.ToLower() ? ContextType.Machine : ContextType.Domain, domain, userName, password))
{
// Check the account credentials for logging onto the domain/machine.
validCredentials = pc.ValidateCredentials(userName, password);
}
result = true;
}
catch (Exception ex)
{
// Failed to validate the credentials, fill in the error message.
errorMsg = ex.Message;
}
return result;
}[/CODE]
InstallScript code to call the .NET dll...
I also wrote this function in InstallScript to split up the username and domain components of the user name...
Which you can call like this...
c# dll method definition...
[CODE][ComVisible(true)]
public bool ValidateAccountCredentials(string domain, string userName, string password, ref bool validCredentials, ref string errorMsg)
{
// The result.
bool result = false;
validCredentials = false;
// Lower the hostname so that matches definately work.
string localHostName = Environment.MachineName.ToLower();
try
{
using (PrincipalContext pc = new PrincipalContext(localHostName == domain.ToLower() ? ContextType.Machine : ContextType.Domain, domain, userName, password))
{
// Check the account credentials for logging onto the domain/machine.
validCredentials = pc.ValidateCredentials(userName, password);
}
result = true;
}
catch (Exception ex)
{
// Failed to validate the credentials, fill in the error message.
errorMsg = ex.Message;
}
return result;
}[/CODE]
InstallScript code to call the .NET dll...
prototype Util_ValidateAccountCredentials(STRING, STRING, STRING, BYREF BOOL);
function Util_ValidateAccountCredentials(sDomain, sUserName, sPassword, bvValidCredentials)
OBJECT oAccountManagement;
BOOL bvResult;
STRING svErrorMsgFromDll, svExceptionErrorMsg;
begin
SdShowMsg("Validating the " + sDomain + "\\" + sUserName + " account credentials...", TRUE);
// We don't want to log this.
Disable(LOGGING);
// Network credentials are invalid until we found out they are valid.
bvValidCredentials = FALSE;
try
// Create an object to talk to the account management class of the InstallLibrary.
set oAccountManagement= DotNetCoCreateObject(SUPPORTDIR ^ "InstallLibrary.dll", "MyCompany.MyProduct.InstallLibrary.AccountManagement, "MyCompany.MyProduct.InstallLibrary");
// Test whether the network credentials are valid.
bvResult = oAccountManagement.ValidateAccountCredentials(
sDomain + "",
sUserName + "",
sPassword + "",
bvValidCredentials,
svErrorMsgFromDll);
// Check the result.
if (bvResult = FALSE) then
MessageBox("Error: Unable to validate the " + sDomain + "\\" + sUserName + " account credentials. " + svErrorMsgFromDll, SEVERE);
elseif (bvResult != FALSE && bvValidCredentials = FALSE) then
MessageBox("Error: The " + sDomain + "\\" + sUserName + " account credentials are not valid.", SEVERE);
else // Success
// Do nothing
endif;
// Clean up object.
set oAccountManagement = NOTHING;
// Unload app domain.
DotNetUnloadAppDomain("MyCompany.MyProduct.InstallLibrary");
catch
Sprintf(svExceptionErrorMsg, "Unable to validate the " + sDomain + "\\" + sUserName + " account credentials.\n%i\n\n%s\n\n%s.\n%s.", Err.Number, Err.Description, Err.LastDllError, svErrorMsgFromDll);
MessageBox("Error: " + svExceptionErrorMsg, SEVERE);
endcatch;
// Start logging again.
Enable(LOGGING);
SdShowMsg("Validating the " + sDomain + "\\" + sUserName + " account credentials...", FALSE);
end;
I also wrote this function in InstallScript to split up the username and domain components of the user name...
prototype Util_GetComponentsFromAccountName(STRING, BYREF STRING, BYREF STRING);
function Util_GetComponentsFromAccountName(sAccountName, svDomain, svUsername)
LIST listID;
BOOL bvResult;
begin
// Failed to complete task, until we know otherwise.
bvResult = FALSE;
svDomain = "";
svUsername = "";
// Create a list to get the tokens of the string into.
listID = ListCreate (STRINGLIST);
// Get the tokens of the string into the list.
if (StrGetTokens(listID, sAccountName, "\\") = 0) then
if (ListGetFirstString(listID, svDomain) = 0) then
if (StrLength(svDomain) > 0) then
if (ListGetNextString(listID, svUsername) = 0) then
if (StrLength(svUsername) > 0) then
bvResult = TRUE;
endif;
endif;
endif;
endif;
endif;
if (bvResult = FALSE) then
MessageBox("Error: Failed to determine the domain and/or username from the '" + sAccountName + "' text.", SEVERE);
endif;
end;
Which you can call like this...
STRING svDomainName, svUserName;
Util_GetComponentsFromAccountName("MyDomain\\MyUser", svDomainName, svUserName);